Use is
when you want to check against an object‘s identity (e.g. checking to see if var
is None
). Use ==
when you want to check equality (e.g. Is var
equal to 3
?).
ref: http://stackoverflow.com/questions/14247373/python-none-comparison-should-i-use-is-or
时间: 2024-12-19 16:02:18