python查找列表中的重复元素

https://blog.csdn.net/qq284489030/article/details/79507161

from collections import Counter

aa=[1,2,2,3,2,4]

然后Counter(aa),即可得到一个显示出所有元素重复次数的dict。

Counter({2: 3, 1: 1, 3: 1, 4: 1})

猜你喜欢

转载自blog.csdn.net/whyerdiku/article/details/81134239