class A(object):
def __init__(self):
# self.x1 = {}
object.__setattr__(self, "x", {})
# def __getattr__(self, item):
# print(item)
def __setattr__(self, key, value):
print(self.x)
print(key, value)
self.x[key] = value
print(self.x)
a = A()
a.name = "chr"
来源:CSDN
作者:CHR_YTU
链接:https://blog.csdn.net/qq_44291044/article/details/104479001