python去除列表(数组)里的重复记录

2022-03-15 00:00:00 数组 重复 去除
#方法1:
>>> mylist = [3,5,8,5,3,12]
>>> print dict().fromkeys(mylist).keys()
[8, 3, 12, 5]
>>>

#方法2:
>>> mylist = [3,5,8,5,3,12]
>>> print list(set(mylist))
[8, 3, 12, 5]
>>>

相关文章