擅长:python、mysql、java
<p>我会用<code>zip()</code>:</p>
<pre><code>In [25]: l1 = [('a', 2), ('b', 3), ('z', 5)]
In [26]: l2 = [('a', 1), ('b', 2), ('c', 3)]
In [27]: [x[0] for x,y in zip(l1,l2) if x[0]==y[0]]
Out[27]: ['a', 'b']
</code></pre>
<p><strong>编辑:</strong>在阅读了您在上面的评论后,您似乎在寻找以下内容:</p>
<pre><code>In [36]: [x[0] for x in l1 if any(x[0]==y[0] for y in l2)]
Out[36]: ['a', 'b']
</code></pre>
<p>或者使用<code>sets</code>:</p>
<pre><code>In [43]: from operator import itemgetter
In [44]: set(map(itemgetter(0),l1)) & set(map(itemgetter(0),l2))
Out[44]: set(['a', 'b'])
</code></pre>