第一种写法:通过set特性去重,但是不保证顺序,无序的
a = ["1", 1, "1", 2]
a = list(set(a))
print(a)
结果:
[1, 2, '1']
第二种写法:可以保证和原来顺序一样
a = ["1", 1, "1", 2]
b = []
for i in a:
if i not in b:
b.append(i)
print(b)
结果:
['1', 1, 2]
标签:set,Python,重复,顺序,移除,print,写法
From: https://www.cnblogs.com/gaohongyu/p/17651734.html