class Foo:
    def __init__(self,x):
        self.x = x

    def __getattr__(self, item):
        print("调用__getattr_方法")

    # 不管有没有属性,都会调用该方法
    def __getattribute__(self, item):
        print("调用__getattribute__方法")
        raise  AttributeError("抛出异常---") # 当抛出 AttributeError时,会调用__getattr__方法

f = Foo(10)
f.x  # f中有x属性
f.xxx  # f中没有xxx属性