Is there a difference between `==` and `is` in Python?

There is a simple rule of thumb to tell you when to use == or is.

  • == is for value equality. Use it when you would like to know if two objects have the same value.
  • is is for reference equality. Use it when you would like to know if two references refer to the same object.
>>> a =
>>> b =
>>> a == b
True
>>> a is b
False

注: 判断None的只能用xxx is None来做

ref: http://*.com/questions/132988/is-there-a-difference-between-and-is-in-python

https://segmentfault.com/q/1010000000150947

上一篇:java:序列化Serializable 接口


下一篇:Altium Designer快捷键 【worldsing笔记】