标签: python duplicates
说我有一个清单
list = ["1","2","1","3"]
我希望摆脱重复的1'但我想保留一份副本以便列表显示
list = ["1","2","3"]
我知道我可以使用set()来删除重复项,但是我无法保留副本。我该如何保留副本?
答案 0 :(得分:2)
使用set,然后再将其转换为list
set
list
lists = ["1","2","1","3"] new_list = list(set(lists))