标签:turn 高级 sys json python efault library blog lib
from collections import defaultdict import json def tree(): return defaultdict(tree) categories = tree() a = categories[‘Programming Languages‘][‘Python‘] b = categories[‘Programming Languages‘][‘java‘] a[‘Standard Library‘][‘sys‘]=‘sys‘ a[‘Standard Library‘][‘os‘]=‘os‘ b[‘Standard Library‘][‘os‘]=‘jos‘ print(json.dumps(categories)) 输出: {"Programming Languages": {"Python": {"Standard Library": {"sys": "sys", "os": "os"}}, "java": {"Standard Library": {"os": "jos"}}}}
标签:turn 高级 sys json python efault library blog lib
原文地址:http://www.cnblogs.com/wt11/p/7383668.html