`
java-mans
  • 浏览: 11454653 次
文章分类
社区版块
存档分类
最新评论

消去Python中list的重复元素

 
阅读更多

原文地址:http://www.peterbe.com/plog/uniqifiers-benchmark

Fastest way to uniqify a list in Python

Suppose you have a list in python that looks like this:

[ 'a' , 'b' , 'a' ]
#orlikethis:
[ 1 , 2 , 2 , 2 , 3 , 4 , 5 , 6 , 6 , 6 , 6 ]

and you want to remove all duplicates so you get this result:

[ 'a' , 'b' ]
#or
[ 1 , 2 , 3 , 4 , 5 , 6 ]


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics