我需要检查某些属性是否存在,比如:
if "blah-blah-blah" is None:
print "there is no such attribute"
else:
print "The attribute exists"
if "blah-blah-blah" is None:
print "there is no such attribute"
else:
print "The attribute exists"
whatever == None
应该写成whatever is None
。 - Jon Clements