擅长:python、mysql、java
<p>我的建议是:</p>
<pre><code>c = [x for x in b if x not in a]
</code></pre>
<p>作为一个<a href="http://docs.python.org/2/tutorial/datastructures.html#list-comprehensions" rel="nofollow">list comprehension</a>,写起来非常简单,效率也很高。你知道吗</p>
<p>希望这有帮助!你知道吗</p>
<p><strong>更新</strong>:</p>
<p>要更有效地检查成员身份,请使用<code>set</code>而不是<code>list</code>。你知道吗</p>
<pre><code>a = set(a)
c = [x for x in b if x not in a]
</code></pre>
<p>这会更快,更不用说在<code>list</code>很大时的改进了。你知道吗</p>