python动态添加属性
2020-12-13 13:44
阅读:286
标签:item sel self __init__ get span div att class python动态添加属性 标签:item sel self __init__ get span div att class 原文地址:https://www.cnblogs.com/7134g/p/11536014.html
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__)
评论
亲,登录后才可以留言!