inp = "this is a string I want to parse because it mentions IOT"
ignored = ['this', 'is', 'are', 'a', 'to','it','from']
result = [item for item in inp.split() if item not in ignored]
print(result)
将所有忽略的术语添加到
ignored
列表。在这里,我们使用列表理解来计算
result
. 我们可以选择使用
for