回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我试过以下方法:</p>
<pre><code>vrs = [('first text', 1),
('second text', 2),
('third text', 3),
('fourth text', 4),
('fifth text', 5),
('sixth text', 6),
('seventh text', 7),
('eighth text', 8),
('ninth text', 9),
('tenth text', 10),
('eleventh text', 11),
('twelfth text', 12)
]
if all(vr is tuple for vr in vrs):
print('All are tuples')
else:
print('Error')
if set(vrs) == {tuple}:
print('All are tuples')
else:
print('Error')
</code></pre>
<p>两者的输出都是<code>Error</code>。在</p>
<p>有没有什么方法可以不用循环来检查这一点(即检查列表中的每个元素是否都是元组)?在</p>