您的位置:首页 > 编程语言 > Python开发

python 删除/查找重复项

2017-03-19 10:52 267 查看
l = [1,2,3,2,1]

# l = ['你','我','他','她','你']  
for i in l:
print("the %s has found %s" % (i, l.count(i)))          #find duplicate number
# print("the %s has found %s" % (i, l.count(i)))     #find duplicate string
#the method above would repeat count duplicate data ,so we need to remove duplicate first
print 'split line ----------------------------'
s = set(l)
for j in s:
print("the %s has found %s" % (j, l.count(j)))      #find duplicate number


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: