from random Import randint
data = [randint(0,20) for _ in range(30)] //产生0-20的随机数30个作为一个列表
// 方式一:
c1 = dict.fromkeys(data,0)
for x in data:
c1[x] +=1
// 方式二:
from collections import Counter
c2 = Counter(data) //c2的结果和方式一最后结果的c1相同
c2.most_commom(3) //频度最高的前三的元组 return:[(7,9),(1,8),(2,7)]