擅长:python、mysql、java
<blockquote>
<p>even though If is true?</p>
</blockquote>
<p><strong>永远不要假设这一点。密码没有说谎。你知道吗</p>
<p>当<code>type(r)</code>实际上是一个<code>int</code>(没有引号)时,<code>type(r) == 'int'</code>永远不会为真</p>
<p>试试<code>print(type(r) == 'int')</code></p>
<hr/>
<p>别把你的类型串起来。你知道吗</p>
<p>例如,<code>isinstance(r, int)</code>确实看起来更好</p>
<p>至于检查列表、集合、元组等</p>
<p><a href="https://stackoverflow.com/questions/1952464/in-python-how-do-i-determine-if-an-object-is-iterable">In Python, how do I determine if an object is iterable?</a></p>