<分区>
Possible Duplicate:
How does Python compare string and int?
我正在用 Python 做一些比较。我惊讶地发现我可以将字符串与整数进行比较。然后我做了一个 id,发现实际上字符串的 id 大于 int 的 id,我认为这就是我得到这个输出的原因。
In [19]: 'a' < 3
Out[19]: False
In [20]: 'a'>3
Out[20]: True
In [17]: id('a')
Out[17]: 140414909035824
In [18]: id(3)
Out[18]: 23119752
请确认我正确解释了此行为(Python 在 id 级别进行比较)。