统计列表中有重复的元素

代码

from collections import Counter
ll=['1','1','2','3']

dic=dict(Counter(ll))
print(dic)
print([k for k,v in dic.items() if v>=2])

猜你喜欢

转载自www.cnblogs.com/tjp40922/p/12617035.html
今日推荐