标签: 面试题
- 使用map的fromkeys 来自动过滤重复值
a = [1, 2, 3, 4, 2, 1, 4, 5, 6, 3]
}
b = {}
b = b.fromkeys(a)
print(b)
a = list(b.keys())
print(a)
- 利用set(),set定义是定义集合的,无序,不重复
a = list(set(a))
print(a)
标签: 面试题
a = [1, 2, 3, 4, 2, 1, 4, 5, 6, 3]
}
b = {}
b = b.fromkeys(a)
print(b)
a = list(b.keys())
print(a)
a = list(set(a))
print(a)
本文标题:Python代码实现删除一个list里面的重复元素
本文链接:https://www.haomeiwen.com/subject/skgjsftx.html
网友评论