打印不在 txt 文件中的单词

问题描述 投票:0回答:0

我有 2 个文件,第一个是推文列表。第二个是标准单词列表,如下所示:

acoustics
acquaint
acquaintable
tbc....

我想遍历推文列表并打印在标准单词列表中找不到的单词。

这是我试过的:

with open("wordslist.txt") as f: words_list = {word.removesuffix(" ") 对于 f}

中的单词

with open("tweets.csv") as g: 对于 g 中的推文: 对于 tweets.split() 中的单词: 如果单词不在 words_list 中: 打印(单词)

它仍然打印出

wordslist.txt

中的单词
python loops for-loop jupyter-notebook sentiment-analysis
© www.soinside.com 2019 - 2024. All rights reserved.