用集合的天然去重

list1=[11,22,33,44,33,22]
list2=list(set(list1))
print(list2)
#[33, 11, 44, 22]

用字典的key

a=[12,3,3,3,44,44,22]
d={}
b=d.fromkeys(a)
c=list(b.keys())
print(c)
#[12, 3, 44, 22]

 

相关文章:

  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2021-05-25
  • 2021-08-06
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
相关资源
相似解决方案