python list 去除重复

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



原文地址:https://www.cnblogs.com/phoenix13suns/p/2330264.html