【发布时间】:2010-10-11 06:51:51
【问题描述】:
在 Python 中有没有办法确定一个对象是否具有某些属性?例如:
>>> a = SomeClass()
>>> a.someProperty = value
>>> a.property
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: SomeClass instance has no attribute 'property'
在使用之前如何判断a 是否具有property 属性?
【问题讨论】:
标签: python attributes