Python 中 is 与 == 的区别

引述官方文档

Value comparisons: 
    The operators "<", ">", "==", ">=", "<=", and "!=" compare the values
of two objects.  The objects do not need to have the same type.

Identity comparisons:
    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.  Object identity
is determined using the "id()" function.  "x is not y" yields the
inverse truth value.
  • 由官方文档解释可知:
    • is 判断的是两个对象的ID
    • == 判断的是两个对象的值
—— 结束 ——