python的list去除重复
我直接上脚本:
方法1:
#!/usr/bin/env python
n = [1,2,3,3,4,3,1,2,3,2,1,4,5,5,5,5,6,6,4,3,2,1,2,6,8,2]
m = []
for x in n:
if x not in m:
m.append(x)
print m
效果:
方法2:
利用set去重复:
#!/usr/bin/env Python
staff_list = ['aa','bb','aa','bb','cc','aa','cc','bb']
print list(set(staff_list))
效果:
相关文章