from types import MappingProxyType
d={"1":"A"}
d_proxy=MappingProxyType(d)
d_proxy["1"]="B" #对d_proxy修改会报错
d["2"]="C" #d_proxy随着d的修改而发生变化
print(d_proxy)
print(d)
转载于:https://www.cnblogs.com/c-x-a/p/10029740.html
from types import MappingProxyType
d={"1":"A"}
d_proxy=MappingProxyType(d)
d_proxy["1"]="B" #对d_proxy修改会报错
d["2"]="C" #d_proxy随着d的修改而发生变化
print(d_proxy)
print(d)
转载于:https://www.cnblogs.com/c-x-a/p/10029740.html