phoenix13

导航

 

1.单个元素去重

if e not in myList:
myList.append(e)

2.把一个list去重后放入另一个list

total=['1','2','3']
so=['1','4']

[total.append(e) for e in so if not e in total]

print total

 

http://www.peterbe.com/plog/uniqifiers-benchmark/    Fastest way to uniqify a list in Python



posted on 2012-01-27 22:38  phoenix13  阅读(815)  评论(0编辑  收藏  举报