开发者

whats the difference between "is not" and " !=" in Python [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

Is there any difference between “foo is None” and “foo == None”?

Python '==' vs 'is' comparing strings, 'is开发者_运维问答' fails sometimes, why?

Hi, im doing some checks on argvs in python and running from the windows cmd

python script.py 2.zap

This works(rises the desired Exception):

from sys import argv    
if argv[1][-3:] != "zip":
        raise Exception()

But this doesnt

from sys import argv    
    if argv[1][-3:] is not "zip":
        raise Exception()

Could you explain the difference, thanks in advance. I'm using python 3 if thats relevant.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜