统计列表中有重复的元素
代码
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])
代码
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])