我经常需要检查类的实例是否具有属性,如果该属性存在,则与其值进行比较.除了以下之外没有办法吗?
if house.garage: if house.garage == '3 car': # do something with house.garage
python
python ×1