擅长:python、mysql、java
<p>您可以执行以下操作:</p>
<pre><code>>>> ' '.join([word for word in mainsentence.split() if not any([stopword in word for stopword in stopwords])])
'My apple and me'
</code></pre>
<p>编辑:这不需要双向检查,只需查看word是否包含stopword<br/>
EDIT2:更新了结果和更新的问题参数</p>
<p>不区分大小写的版本:</p>
<pre><code>' '.join([word for word in mainsentence.split() if not any([stopword.lower() in word.lower() for stopword in stopwords])])
</code></pre>