Python 'is' vs JavaScript ===

前端 未结 4 1436
一向
一向 2021-02-04 03:01

The Python use of \'is\' seems to be similar to JavaScript \'===\' but not quite.

Here they talk about exact instances: http://www.learnpython.org/en/Conditions

<
4条回答
  •  深忆病人
    2021-02-04 03:50

    Completely different.

    >>> a = 'foo'
    >>> b = 'bar'
    >>> a + b is 'foobar'
    False
    >>> 1000 + 1 is 1001
    False
    

提交回复
热议问题