class A: def __init__(self, info ={}): self.info = info def __getattr__(self, item): return self.info[item] a =A() a.age = 123 print(a.age) a.name = 123 print(a.name) a.xis = 123 print(a.xis) print(a.__dict__)
class A: def __init__(self, info ={}): self.info = info def __getattr__(self, item): return self.info[item] a =A() a.age = 123 print(a.age) a.name = 123 print(a.name) a.xis = 123 print(a.xis) print(a.__dict__)