Feng’ Blog

Python对list去重复
方法一:ids = [1,2,3,3,4,2,3,4,5,6,1] news_ids = [] for id in...
扫描右侧二维码阅读全文
09
2019/01

Python对list去重复

方法一:

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

2 comments

  1. jalena

    你好,HMP

    1. 博主
      @jalena

      你也好,HMPφ( ̄∇ ̄o)

Leave a Comment