可能重复:
Is there any difference between “foo is None” and “foo == None”?
Python '==' vs 'is' comparing strings, 'is' fails sometimes, why?
嗨,我正在对python中的argv进行一些检查,并从windows cmd运行
python script.py 2.zap
这有效(提升所需的例外):
from sys import argv
if argv[1][-3:] != "zip":
raise Exception()
但这不是
from sys import argv
if argv[1][-3:] is not "zip":
raise Exception()
你能否提前解释这个区别?我正在使用python 3,如果那是相关的。