0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

除外リスト

Last updated at Posted at 2020-11-28

#リストから除外したい文字列を含むものを除く

すらすらかけなかったから、メモとして残す。(頭固いな。。。)

exclude_list = ["hoge", "fuga", ] # sources からhoge, fugaを含む要素を除去
sources = filter(lambda e: all(x not in e for x in exclude_list), sources)
print(list(sources))

正規表現とかでも書けるけど、pythonの正規表現は行儀が良すぎて使いにくい。perl,sedのように"~"で書けると楽なんだけど。。。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?