首页 > 编程语言 > 详细

python 删除/查找重复项

时间:2017-03-19 13:31:46      阅读:240      评论:0      收藏:0      [点我收藏+]

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

技术分享

 

python 删除/查找重复项

原文:http://www.cnblogs.com/vickey-wu/p/6579653.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!