我有一個大名單,看起來是這樣的:從缺乏某些字符串列表中刪除元素 - 蟒蛇
entries = ["['stuff']...other stuff", "['stuff']...stuff", "['stuff']...more stuff", ...]
我想刪除列表做的所有元素不包含單詞「其他」或「東西」。
我試過,但它沒有消除所有我需要它(只有一些接近尾聲)的元素:
for e in entries:
if 'other' or 'things' not in e:
entries.remove(e)
print entries
我在做什麼錯?
另外,請注意,[this](https://stackoverflow.com/questions/1157106/remove-all-occurrences-of-a-value-from-a-list)將是您的下一個bug ... –
誰重新打開了這個?這顯然是[this]的重複**(https://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values) –