Are*_*res 3 javascript python comparison
我在这里看到了这个问题,现在我很好奇.is与JS中的===符号相比,运算符在python中的行为如何?
不,他们不一样.is在Python中检查两个对象在Python中是否相同id,即.即使在记忆中,它们也是一样的.您可以检查的是:
>>> a='foo'
>>> a is 'foo'
True
>>> id(a)
44434088
>>> id('foo')
44434088
>>> a=[1]
>>> a is [1]
False
>>> id(a)
45789792
>>> id([1])
4469824
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
134 次 |
| 最近记录: |