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"
setattr和getattr的理解
猜你喜欢
转载自blog.csdn.net/qq_44291044/article/details/104479001
今日推荐
周排行