消去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 ]


你可能感兴趣的:(python)