码迷,mamicode.com
首页 > 其他好文 > 详细

Day1作业-三级菜单

时间:2017-11-06 12:12:33      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:三级菜单   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 ")


Day1作业-三级菜单

标签:三级菜单   index   bre   close   conf   菜单   utf-8   while   /usr   

原文地址:http://www.cnblogs.com/jenvid/p/7792447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!