json menu(): file=(,,=) str=f (): str=str+file.readline() =json.loads(str) file.close() dict=menu() wl(dc): : m dc: (m,(m)) butter=() butter dc: wl(dc[butter]) butter == : () butter == : k1 dict.keys(): m dict.keys() m dict[k1].keys(): olddc=dict wl(olddc) k2 dict[k1].keys(): m dict[k1][k2]: olddc=dict[k1] wl(olddc) k3 dict[k1][k2].keys(): m dict[k1][k2][k3]: olddc=dict[k1][k2] wl(olddc) : () wl(dict)
---------------------------------------------------
文件内容以字典形式
{ "北京市":{ "东城区":{ "东四":["地铁站"], "灯市口":["汽车站"] }, "西城区":{ "阜成门":["南礼士路","金融街"], "复兴门":["远洋大厦","人民电视台","三里河"] }, "朝阳区":{ "亮马桥":["希尔顿","蓝色港湾"], "团结湖":["朝阳公园","京客隆","甜水园"], "呼家楼":["金泰熙"], "望京":[798,347,891] } }, "河北省":{ "石家庄市":{ "长安区":{ "北宋":["何妨小区"], "河东":["钟声广场"] }, "桥西区":{ "新石":["新生活"], "振头":["汇华广场"] }, "新华区":{ "东焦":["永泰中街","宁源小学","河北省人民医院","市二中"], "合作路":["膏药章","张家口银行","光大银行",887], "中山":["中国银行","新百广场","太和大厦"], "西里":["天主堂","眼科","裕华大酒店",773] } }, "唐山市":{ "路南区":{ "双新里":["二十六中"], "卫国楼":["妇幼保健院","联合大厦"], "光明里":["锦江国际酒店"] }, "路北区":{ "金隅乐府":["草场楼",776,441], "国防东道":["新建路"], "凤凰道":["4321"] } } } }
时间: 2024-10-25 15:39:57