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



相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-03-06
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案