交换变量值
a, b = 5, 10
print(a, b) # 5 10
a, b = b, a
print(a, b) # 10 5
将列表中的所有元素组合成字符串
a = ['Python', 'is', 'awesome']
print(' '.join(a)) # Python is awesome
查找列表中频率最高的值
a = [1, 2, 3, 1, 2, 3, 2, 2, 4, 5, 1]
print(max(set(a), key = a.count)) # 2
from collections import Counter
count = Counter(a)
print(count.most_common()) # [(2, 4), (1, 3), (3, 2), (4, 1), (5, 1)]
检查两个字符串是不是由相同字母不同顺序组成
from collections import Counter
str1 = 'Hello Word'
str2 = 'Word Hello'
print(Counter(str1) == Counter(str2)) # True