2.2.1 定義命名元祖
2.2.2 定義雙端隊列
2.2.3 定義有序的字典
2.2.4 定義有默認值的字典
2.2.5 計數器
from collections import Counter li = [2, 5, 3, 4, 1, 8, 1, 2, 6, 6, 1, 5, 1, 5] c = Counter(li) print(c) # Counter({1: 4, 5: 3, 2: 2, 6: 2, 3: 1, 4: 1, 8: 1}) print(c.most_common(3)) # [(1, 4), (5, 3), (2, 2)]