What is the difference between “ is None ” and “ ==None ”

后端 未结 5 920
无人共我
无人共我 2020-11-22 11:33

I recently came across this syntax, I am unaware of the difference.

I would appreciate it if someone could tell me the difference.

5条回答
  •  囚心锁ツ
    2020-11-22 11:56

    class Foo:
        def __eq__(self,other):
            return True
    foo=Foo()
    
    print(foo==None)
    # True
    
    print(foo is None)
    # False
    

提交回复
热议问题