<分区>
Possible Duplicate:
Python “is” operator behaves unexpectedly with integers
在 python 2.6.6 中,当我使用 int() 将字符串转换为数字时,如果字符串为 257 或更大,则以下代码的行为不正确。
curr = int("256")
myint = int("256")
if curr is myint:
print("true")
else:
print("false")
这会返回正确的 true
curr = int("257")
myint = int("257")
if curr is myint:
print("true")
else:
print("false")
这会返回 false ???