为什么用Python "hello" is "hello"生成True?
"hello" is "hello"
True
我在这里阅读以下内容:
如果两个字符串文字相等,则它们被放在相同的内存位置.字符串是不可变的实体.不会造成伤害.
因此,每个Python字符串在内存中只有一个位置?听起来很奇怪.这里发生了什么?
python identity string-comparison object-comparison
identity ×1
object-comparison ×1
python ×1
string-comparison ×1