Python列表去重

来源:互联网 发布:php继承多态封装 编辑:程序博客网 时间:2024/05/01 17:55
l = [1,2,3,4,5,6,7,4,3,2,1,4,2,42,45,23,42]newL = list(set(l))print newL

>>> l = [1,2,3,4,5,6,7,4,3,2,1,4,2,42,45,23,42]>>> newL = list(set(l))>>> newL[1, 2, 3, 4, 5, 6, 7, 42, 45, 23]>>> 


0 0