python 生成嵌套字典

import collections
import json

tree=lambda:collections.defaultdict(tree)
some_dict=tree()
some_dict['colours']['favourite']='yellow'
print(json.dumps(some_dict))

 

posted on 2018-12-31 10:45  hailuo  阅读(2562)  评论(0编辑  收藏  举报