方法一:

ids = [1,2,3,3,4,2,3,4,5,6,1]
news_ids = []
for id in ids:
    if id not in news_ids:
        news_ids.append(id)
print news_ids

方法二:

ids = [1,4,3,3,4,2,3,4,5,6,1]
ids = list(set(ids))
Last modification:January 9th, 2019 at 04:36 pm
If you think my article is useful to you, please feel free to appreciate