擅长:python、mysql、java
<p>帮你自己一个忙,用列表理解。那么您就不必担心Python3中的<code>filter</code>不返回<code>list</code>。这同样适用于Python2或Python3</p>
<pre><code>>>> lname1 = [(1, 'one'), (3, 'three'), (5, 'five'), (7, 'seven')]
>>> sKeys = [1, 2, 3]
>>> [(x, y) for x, y in lname1 if x in sKeys]
[(1, 'one'), (3, 'three')]
</code></pre>