码迷,mamicode.com
首页 > 编程语言 > 详细

python 删除/查找重复项

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

标签:alt   dup   print   split   pytho   str   技术分享   logs   height   

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 删除/查找重复项

标签:alt   dup   print   split   pytho   str   技术分享   logs   height   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!