擅长:python、mysql、java
<p>如果我没听错,这可能会有帮助。</p>
<p>设置排除列表:</p>
<pre><code>exclude= ["food", "staging", "msatl", "azeus"]
</code></pre>
<p>测试列表(我在您的示例中找不到实例)</p>
^{pr2}$
<p>运行列表理解(迭代器的名称无关紧要,您可以选择更合适的迭代器)</p>
<pre><code>result= [i for i in test if not any([e for e in exclude if e in i])]
</code></pre>
<blockquote>
<p>result
['a']</p>
</blockquote>
<p>上面@Julian的回答很好地解释了列表理解的作用。这使用其中的两个,如果在<em>排除</em>列表中有任何匹配,<code>any</code>部分是<code>True</code>。<br/>
希望这有帮助。</p>