为什么(0-6)是-6 =假?
今天我试着调试我的项目,经过几个小时的分析,我得到了这个:
>>> (0-6) is -6
False
但,
>>> (0-5) is -5
True
你能解释一下,为什么?也许这是某种错误或非常奇怪的行为。
> Python 2.7.3 (default, Apr 24 2012, 00:00:54) [GCC 4.7.0 20120414 (prerelease)] on linux2
>>> type(0-6)
<type 'int'>
>>> type(-6)
<type 'int'>
>>> type((0-6) is -6)
<type 'bool'>
>>>
慕森卡
皈依舞
相关分类