我需要检查某些属性是否存在。喜欢:
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"
Element
attrib
对象具有字典中的所有属性。
if 'blah' not in elem.attrib:
print "there is no such attribute"