from collections import Counter
a = [1, 1, 7, 3, 6, 2, 5, 4, 4, 3, 9, 4, 4, 1]
#统计列表中重复次数最多的前N个元素
N = 3
print(Counter(a).most_common(N))
#输出是[(4, 4), (1, 3), (3, 2)]
from collections import Counter
a = [1, 1, 7, 3, 6, 2, 5, 4, 4, 3, 9, 4, 4, 1]
#统计列表中重复次数最多的前N个元素
N = 3
print(Counter(a).most_common(N))
#输出是[(4, 4), (1, 3), (3, 2)]