检查另一个字符串中的单词清单

36 浏览
0 Comments

检查另一个字符串中的单词清单

我可以在Python中做这样的事情:

l = ['one', 'two', 'three']
if 'some word' in l:
   ...

这将检查列表中是否存在"some word"。但是我能做相反的事情吗?

l = ['one', 'two', 'three']
if l in 'some one long two phrase three':
    ...

我必须检查数组中的某些单词是否在字符串中。我可以使用循环来实现,但这种方式需要更多的代码行。

0