python 'is not' operator

后端 未结 4 2014
眼角桃花
眼角桃花 2020-12-13 23:47

I notice there is a comparison operator is not. Should I literally translate it into

!= 

instead of

== not
<         


        
4条回答
  •  醉话见心
    2020-12-14 00:27

    python 2.7.3 documentation, 5.9. Comparisons:

    The operators <, >, ==, >=, <=, and != compare the values of two objects.

    and about operator is in the same chapter:

    The operators is and is not test for object identity: x is y is true if and only if x and y are the same object. x is not y yields the inverse truth value.

提交回复
热议问题