标签:三级菜单 index bre close conf 菜单 utf-8 while /usr
# /usr/bin/env python
# -*- coding: utf-8 -*-
# Author:jenvid.yang
import json
filecontent = open(‘../config/menue.json‘)
content = json.load(filecontent)
print(type(content))
filecontent.close()
while True:
for i in content:
print(content.index(i), i[‘name‘] + ‘省‘) # 打印每个省的索引和名字
province_id_input = input("pls input province index(q for exit):")
if province_id_input.isdigit():
province_id=int(province_id_input)
if 0 <= province_id <= len(content):
for i in content[province_id][‘city‘]:
print(content[province_id][‘city‘].index(i), i[‘name‘])
while True:
city_id_input = input("pls input city index(b for back/q for exit):")
if city_id_input.isdigit():
city_id = int(city_id_input)
for i in (content[province_id][‘city‘][city_id][‘area‘]):
print(i)
elif city_id_input == ‘q‘:
exit()
elif city_id_input == ‘b‘:
break
else:
print("illge input,pls input again ")
break
elif province_id_input ==‘q‘:
exit()
else:
print("illge input,pls input again ")
标签:三级菜单 index bre close conf 菜单 utf-8 while /usr
原文地址:http://www.cnblogs.com/jenvid/p/7792447.html