问题来源是一个报错
class ggg:
pass
print(ggg.__dict__)
ggg.__dict__["ffff"]=6
报错:
Traceback (most recent call last):
{'__module__': '__main__', '__dict__': <attribute '__dict__' of 'ggg' objects>, '__weakref__': <attribute '__weakref__' of 'ggg' objects>, '__doc__': None}
File "C:/Users/Administrator/PycharmProjects/lianxi1/lianxi1-1/练.py", line 17, in <module>
ggg.__dict__["ffff"]=6
TypeError: 'mappingproxy' object does not support item assignment
总结:不能以class名.__dict__["属性名]=属性值
的方式来修改类属性
一般而言通过class名.属性名=属性值
的方式修改数据属性
原因暂无
另总结修改实例化对象属性内容如下: