# -*- coding: utf-8 -*-
'''
#统计列表重复元素的个数
mylist = [1,2,2,2,2,3,3,3,4,4,4,4]
myset = set(mylist)
for item in myset:
print("the %d has found %d" %(item,mylist.count(item)))
#方法二
List=[1,2,2,2,2,3,3,3,4,4,4,4]
a = {}
for i in List:
if List.count(i)>1:
a[i] = List.count(i)
print (a)
每日算法一技,Python统计列表中重复字数的个数?????
最新推荐文章于 2025-06-05 11:54:14 发布