12 hasattr()vs try-except块来处理不存在的属性 if hasattr(obj, 'attribute'): # do somthing 与 try: # access obj.attribute except AttributeError, e: # deal with AttributeError 应该首选哪个,为什么? 85 python exception exception-handling attributes hasattr