擅长:python、mysql、java
<p>根据我从你的问题中得到的信息,我想你想查一下你名单上的所有单词是否都出现在一个句子中。</p>
<p>一般来说,要搜索列表元素,可以在句子中使用<code>all</code>函数。如果其中的所有参数都为true,则返回true。</p>
<pre><code>listOfWords = ['word1', 'word2', 'word3', 'two words']
sentence = "word1 as word2 a fword3 af two words"
if all(word in sentence for word in listOfWords):
print "All words in sentence"
else:
print "Missing"
</code></pre>
<p><strong>输出</strong>:</p>
<pre><code>"All words in sentence"
</code></pre>
<p>我想这可能符合你的目的。如果没有,你可以澄清。</p>