python 删除/查找重复项
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 删除/查找重复项相关的知识,希望对你有一定的参考价值。
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 删除/查找重复项的主要内容,如果未能解决你的问题,请参考以下文章
删除空格和特殊字符后,ElasticSearch会查找所有重复项