class AttrDict(dict):
"""
http://stackoverflow.com/questions/4984647/\
accessing-dict-keys-like-an-attribute-in-python
http://bugs.python.org/issue1469629
"""
def __init__(self, source):
super(AttrDict, self).__init__(source)
def __getattr__(self, key):
return self[key]
def __setattr__(self, key, value):
self[key] = value
python 字典的扩展变形
最新推荐文章于 2023-10-06 15:50:02 发布