python中运算符‘is’,'is not'和‘==’,’!=‘的区别

is,is not是地址比较

==,!= 是值比较

例如:

>>> la = [1,2,3]
>>> lb = [1,2,3]
>>> id(la)
3076010508L
>>> id(lb)
3076166636L
>>> la == lb
True
>>> la != lb
False
>>> la is not lb
True
>>> la is lb
False

posted @ 2012-03-03 15:20  Stalling  阅读(4463)  评论(0)    收藏  举报