擅长:python、mysql、java
<p>使用<a href="https://docs.python.org/3.4/library/functions.html#isinstance" rel="nofollow">isinstance</a>:</p>
<p><code>isinstance(object, classinfo)</code></p>
<p><em>如果object参数是classinfo参数或其子类(直接、间接或虚拟)的实例,则返回true。</em></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)
]
all(isinstance(x,tuple) for x in vrs)
True
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'
]
all(isinstance(x,tuple) for x in vrs)
False
</code></pre>