class A: def __init__(self, name): self.name = name def __getattr__(self, item): print('执行getattr') def __getattribute__(self, item): print('执行getattribute') raise AttributeError('抛出异常') a1 = A('alex') a1.name a1.age # 235-236
class A: def __init__(self, name): self.name = name def __getattr__(self, item): print('执行getattr') def __getattribute__(self, item): print('执行getattribute') raise AttributeError('抛出异常') a1 = A('alex') a1.name a1.age # 235-236