python 中使用 'is' 要注意其判断值为对象,不要用来判断变量值是否相等

w3school 的解释:

The is keyword is used to test if two variables refer to the same object.
The test returns True if the two objects are the same object.
The test returns False if they are not the same object, even if the two objects are 100% equal.
Use the == operator to test if two variables are equal.

Python is Keyword
说的很清楚了,is 用来判断两个变量是否指向同一个对象,比较变量值应该用 ==

错误示范

原文地址:https://www.cnblogs.com/mrlonely2018/p/15507843.html