循序不做保留
1.使用内置函数 set()
a1 = ['b','c','d','b','c','a','a']
a2 = list(set(a1))
print (a2)
2.使用字典方法fromkeys()-速度更快
a1 = ['b','c','d','b','c','a','a']
a2 = {}.fromkeys(a1).keys()
print (a2)
保留顺序
3.使用list类的sort方法
a1 = ['b','c','d','b','c','a','a']
a2 = list(set(a1))
l2.sort(key=a1.index)
print (a2)
4.另一种写法
a1 = ['b','c','d','b','c','a','a']
a2 = sorted(set(a1),key=a1.index)
print (a2)