方法1
# coding=utf-8
#定义一个字典,将列表重复的字数作为value值,将列表的元素作为键值,存入字典中
#打印出字典
#将字典的键值转化成列表2,即完成了列表去重
list1=[1,1,2,2,3,3,3,4,4,4,4,5,5,5,5,6,6,6,11,12,12]
D1={}
count=0
for i in list1:
count+=1
D1[i]=count
print("D1=",D1)
list2=list(D1.keys())
print("list2=",list2)
方法2
list1=[1,1,2,2,3,3,3,4,4,4,4,5,5,5,5,6,6,6,11,12,12]
list2=list(set(list1))
print("list2",list2)
方法3
list1=[1,1,2,2,3,3,3,4,4,4,4,5,5,5,5,6,6,6,11,12,12]
list2=[]
for i in list1:
if i not in list2:
list2.append(i)
print("list2=",list2)