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

三级菜单

时间:2018-01-21 19:17:25      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:git   als   烟台   苏州   auth   key   输入   name   返回   

#Author:xiesongyou

China= {
‘山东‘ : {
‘青岛‘ : [‘四方‘,‘黄岛‘,‘崂山‘,‘李沧‘,‘城阳‘],
‘济南‘ : [‘历城‘,‘槐荫‘,‘高新‘,‘长青‘,‘章丘‘],
‘烟台‘ : [‘龙口‘,‘莱山‘,‘牟平‘,‘蓬莱‘,‘招远‘]
},
‘江苏‘ : {
‘苏州‘ : [‘沧浪‘,‘相城‘,‘平江‘,‘吴中‘,‘昆山‘],
‘南京‘ : [‘白下‘,‘秦淮‘,‘浦口‘,‘栖霞‘,‘江宁‘],
‘无锡‘ : [‘崇安‘,‘南长‘,‘北塘‘,‘锡山‘,‘江阴‘]
},
‘浙江‘ : {
‘杭州‘ : [‘西湖‘,‘江干‘,‘下城‘,‘上城‘,‘滨江‘],
‘宁波‘ : [‘海曙‘,‘江东‘,‘江北‘,‘镇海‘,‘余姚‘],
‘温州‘ : [‘鹿城‘,‘龙湾‘,‘乐清‘,‘瑞安‘,‘永嘉‘]
},
‘安徽‘ : {
‘合肥‘ : [‘蜀山‘,‘庐阳‘,‘包河‘,‘经开‘,‘新站‘],
‘芜湖‘ : [‘镜湖‘,‘鸠江‘,‘无为‘,‘三山‘,‘南陵‘],
‘蚌埠‘ : [‘蚌山‘,‘龙子湖‘,‘淮上‘,‘怀远‘,‘固镇‘]
},
‘广东‘ : {
‘深圳‘ : [‘罗湖‘,‘福田‘,‘南山‘,‘宝安‘,‘布吉‘],
‘广州‘ : [‘天河‘,‘珠海‘,‘越秀‘,‘白云‘,‘黄埔‘],
‘东莞‘ : [‘莞城‘,‘长安‘,‘虎门‘,‘万江‘,‘大朗‘]
}
}

exit_flag = False
while not exit_flag:
print("省".center(50,‘-‘))
for index,province in enumerate(China):
print(index+1,":",province)
choice_province=input("请选择省编号(输入q退出):")
province_list = list(China.keys())
if choice_province.isdigit():
choice_province = int (choice_province)
if choice_province > 0 and choice_province <= len(province_list):
while not exit_flag :
print("市".center(50, ‘-‘))
province_name=province_list[choice_province - 1]
city = list(China[province_name].keys())
for c in city:
print(city.index(c) + 1, c)
choice_city = input("请选择市(b返回上级菜单,或输入q退出):")
if choice_city.isdigit():
choice_city = int(choice_city)
if choice_city > 0 and choice_city <= len(city):
while not exit_flag:
print("县".center(50, ‘-‘))
city_name = city[choice_city - 1]
country_name = list(China[province_name][city_name])
for ctry in country_name:
print(country_name.index(ctry) + 1, ctry)
country_choice = input("请选择县(b返回上级菜单,或输入q退出):")
if country_choice.isdigit():
country_choice = int(country_choice)
if country_choice > 0 and country_choice <= len(country_name):
print("你的选择是:",province_name,city_name,country_name[country_choice-1])
exit_flag = True
else:
print("输入错误序号!")
elif country_choice == "q":
exit_flag = True
elif country_choice == "b":
break
else:
print("输入序号错误!")
elif choice_city == ‘q‘:
exit_flag = True
elif choice_city == ‘b‘:
break
else:
print("输入序号错误!")
elif choice_province == ‘q‘:
exit_flag = True

三级菜单

标签:git   als   烟台   苏州   auth   key   输入   name   返回   

原文地址:https://www.cnblogs.com/xiesongyou/p/8324857.html

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