【发布时间】:2020-08-20 17:45:43
【问题描述】:
id(A) == id(B) 和 A is B 据我了解,被视为 A 和 B 是否引用同一对象的测试。 (见答案和 cmets Understanding Python's "is" operator)
但是,应用于列表,我们可以得到以下结果:
>>> id(['a', 'b', 'c']) == id(['a', 'b', 'c'])
True
>>> ['a', 'b', 'c'] is ['a', 'b', 'c']
False
有人能解释一下“幕后”究竟发生了什么以促成这种行为吗?
【问题讨论】:
标签: python