每次写 Python 都会忘记该怎么写,最后只能去 Stack Overflow 查?我也一样。时间一长,这让人厌倦。
这 15 个 Python 技巧和窍门,可以帮你提高效率。
x, y = 1, 2
print(x, y)
x, y = y, x
print(x, y)
sentence_list = ["my", "name", "is", "George"]
sentence_string = " ".join(sentence_list)
print(sentence_string)
sentence_string = "my name is George"
sentence_string.split()
print(sentence_string)
[0]*1000 # List of 1000 zeros
[8.2]*1000 # List of 1000 8.2's