缘由:
http://www.reddit.com/r/Python/comments/3a2jlj/why_you_should_almost_never_use_is_in_python
搜索关键字:
python is == difference
参考链接:
- http://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is-in-python
- http://stackoverflow.com/questions/31026754/python-if-not-vs-if
- http://www.reddit.com/r/Python/comments/3a2jlj/why_you_should_almost_never_use_is_in_python
参考解答:
‘is’ will return True if two variables point to the same object, ‘==” if the objects referred to by the variables are equal.
‘==’ 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.
‘is’关键字一般是用来判断两者引用的object是否为同一个;
‘==’一般是用来判断两者引用对象的值是否相等。
=EOF=