首页 技术 正文
技术 2022年11月18日
0 收藏 861 点赞 2,308 浏览 1889 个字
'''程序:三级菜单
要求:
1、打印省、市、县三级菜单
2、可返回上一级
3、可随时退出程序
'''
 # -*- coding: utf-8 -*-
# __author__ = 'qi'
prov_city_conty ={"北京":
{"东城区","西城区","崇文区","宣武区","朝阳区","丰台区","石景山区","海淀区","顺义区"},
"上海":
{"黄埔区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","杨浦区","闵行区"},
"河北":
{
"石家庄市":
{"长安区","桥东区","桥西区","新华区","井陉矿区","裕华区"},
"唐山市":
{"路南区","路北区","古冶区","开平区","丰润区","滦县"}
},
"江苏":
{
"南京市":
{"玄武区","白下区","秦淮区","建邺区","鼓楼区","下关区","浦口区"},
"苏州市":
{"沧浪区","平江区","金阊区","吴中区","相城区","常熟市"}
}
}
while True:
print ("-----打印省菜单------")
for index,prov in enumerate(prov_city_conty,1):
print index, prov
choice_p_menu = raw_input("please select province number[quit:q]:")
if choice_p_menu.isdigit():
choice_p_menu = int(choice_p_menu)
if choice_p_menu>0 and choice_p_menu<len(prov_city_conty):
prov_name_list = prov_city_conty.keys()
prov_name = prov_name_list[choice_p_menu-1]
while True:
print ("-----"+prov_name+"------")
for index,city in enumerate(prov_city_conty[prov_name],1):
print index,city
if prov_name not in ["北京","上海"]:
choice_city_menu = raw_input("please select city number[quit:q]|[return:r]:")
if choice_city_menu.isdigit():
choice_city_menu = int(choice_city_menu)
if choice_city_menu>0 and choice_city_menu<len(prov_city_conty[prov_name]):
city_name_list = prov_city_conty[prov_name].keys()
city_name = city_name_list[choice_city_menu-1]
while True:
print ("-----"+city_name+"------")
for county in prov_city_conty[prov_name][city_name]:
print county
choice_q_r_menu = raw_input("please select [quit:q]|[return:r]:")
if choice_q_r_menu == "q":
exit()
elif choice_q_r_menu == "r":
break
else:
print("your input code %s is not exist!" %choice_q_r_menu)
continue
else:
print ("city code %s is not exist!" %choice_city_menu)
continue
elif choice_city_menu == "q":
exit()
elif choice_city_menu == "r":
break
else:
choice_q_r_menu = raw_input("please select [quit:q]|[return:r]:")
if choice_q_r_menu == "q":
exit()
elif choice_q_r_menu == "r":
break
else:
print("your input code %s is not exist!" %choice_q_r_menu)
continue
else:
print ("province code %s is not exist!" %choice_p_menu)
elif choice_p_menu == "q":
break
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,075
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,551
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,399
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,811
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,893