gpt4 book ai didi

python - 是 Python 中的运算符

转载 作者:行者123 更新时间:2023-11-28 22:03:34 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Python “is” operator behaves unexpectedly with integers
How is the 'is' keyword implemented in Python?

我对 python 中的“is”运算符有疑问:

>>> a = "1234"
>>> b = "1234"
>>> a is b
True
>>> a = "12 34"
>>> b = "12 34"
>>> a is b
False

谁能解释一下为什么会这样?我也无法理解,据说“is”运算符只需要比较对象的内存地址,那么表达式“a is b”是否为真?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com