Python simple not in 语句不起作用

时间:2021-02-25 01:12:21

标签: python list if-statement

在 python 中,我试图运行此代码:

    blacklist = ['hello', 'man']
    for word in open("text.txt"):
      if word not in blacklist:
          print(word)

在 text.txt 我有

test hello man

我希望输出为:

test

但是 - 它只返回 text.txt 的文本! 有什么问题?

0 个答案:

没有答案