如何运用PYTHON里的Counter
1、from collections import Counterabc = [1,2,454,3,6,3,1,3,5,6,8荑樊综鲶,4,3,8,4,2,1,2,3,]counts = Counter(abc)print(counts)引进模块函数,然后直接统计每个数字出现的次数。

3、none = counts[322]print(none)如果没有的数字会显示0。

5、counts[454] = 0print(counts[454])print(counts)可以吧次数更改为0次。

7、ooo = list(counts.elements())print(ooo)可以整理一下为一个新的列表。

9、i = counts.most_common(2)print(i[0][0])出现次数最频繁的具体哪个数字,不需要其他数据也可以这样显示。
