统计列表中有重复的元素

代码

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])

 

posted @ 2020-04-02 00:19  阿布_alone  阅读(557)  评论(0编辑  收藏  举报
TOP