我正在我的应用程序中使用dotdict:
class dotdict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
这项工作:
test = dotdict({})
test.foo = "bar"
但是,这不起作用,因为我得到'NoneType' object does not support item assignment
:
test = dotdict({})
test.foo[0] = "bar"
我想知道是否有办法更改setattr,以自动创建一个特定大小的数组,这样我就不会出错?多谢各位
目前没有回答
相关问题 更多 >
编程相关推荐