擅长:python、mysql、java
<p>如果我正确理解了要求,这应该可以满足您的要求:</p>
<pre><code>jen = (34,54,15), (34,65,15), (34, 78,89)
salvation_army = [j for j in jen if j[2] == jen[0][2]]
print(salvation_army)
# Output:
# [(34, 54, 15), (34, 65, 15)]
</code></pre>
<p>它类似于@Harsh的答案,但是使用列表理解而不是<code>filter</code>(这是品味的问题。)</p>
<p>你想做的是:</p>
<pre><code>salvation_army = []
desired_value = jen[0][2]
for line in jen:
if line[2] == desired_value:
salvation_army.append(line)
</code></pre>