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
- 上一篇 »python去除重复元素
- 下一篇 »PYTHON去除重复元素2