【发布时间】:2017-02-21 09:03:14
【问题描述】:
我在 python 控制台中运行这个command:
为什么两个结果不同?
>>>S1 = 'HelloWorld'
>>>S2 = 'HelloWorld'
>>>S1 is S2
True
>>>S1 = 'Hello World'
>>>S2 = 'Hello World'
>>>S1 is S2
False ---------i think the result is True,why it is False
【问题讨论】:
-
这是一种常见的行为。请参阅以下主题:Identity testing vs Equality testing
-
特别是,请参阅副本中的this answer。
-
在使用 pycharm 运行代码时, 在这两种情况下都会给出
true
标签: python