📅  最后修改于: 2022-03-11 14:46:17.705000             🧑  作者: Mango
class Foo(object):
def __init__(self):
self.bar = "bar attribute"
def __getattr__(self, attr):
return attr.upper()
foo = Foo()
print(foo.bar) # Output: bar attribute
print(foo.another_no_exist_attribute) # Output: ANOTHER_NO_EXIST_ATTRIBUTE
print(foo.itworks) # Output: ITWORKS