ITeye博客

python去除列表里的重复记录

logo32 · 2019-09-03 11:14 · 编程语言 · Markdown

#方法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]
>>>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。