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

多级菜单实现

时间:2017-06-19 19:40:43      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:编程   country   log   rom   count   while   logs   贵州   back   


 1 __author__ = ‘ZZG‘
 2 ‘‘‘
 3 这个程序只用来测试中国,另外实现到省一级别。(国家-地区-省份)
 4 
 5  ‘‘‘
 6 p1 = [‘北京‘,‘天津‘,‘河北‘,‘山西‘,‘内蒙古‘]
 7 p2 = [‘湖北‘,‘湖南‘,‘河南‘,‘江西‘]
 8 p3 = [‘广东‘,‘广西‘,‘海南‘]
 9 p4 = [‘山东‘,‘江苏‘,‘安徽‘,‘浙江‘,‘上海‘,‘福建‘]
10 p5 = [‘辽宁‘,‘吉林‘,‘黑龙江‘]
11 p6 = [‘四川‘,‘云南‘,‘贵州‘,‘西藏‘,‘重庆‘]
12 p7 = [‘宁夏‘,‘新疆‘,‘青海‘,‘陕西‘,‘甘肃‘]
13 p8 = [‘香港‘,‘澳门‘,‘台湾‘]
14 
15 region = [‘华北‘, ‘华中‘, ‘华南‘, ‘华东‘, ‘东北‘, ‘西南‘, ‘西北‘, ‘港澳台‘]
16 province = [p1, p2, p3, p4, p5, p6, p7, p8]
17 adict = dict(zip(region,province))
18 #print(adict)
19 country = ("China",‘America‘,‘Kereo‘,‘Japen‘,‘Europe‘)
20 print(country)
21 
22 while True:
23     w_country = input(‘please enter your  country from up-list or enter "Back" to return:‘)
24 
25     if w_country == "China":
26         print(region)
27         w_region = input(‘please enter your region of country or enter "Back" to return:‘)
28         if w_region == ‘Back‘:
29             print(country)
30         else:
31             print(adict[w_region])
32 
33     elif w_country == ‘Back‘:
34         print("China",‘America‘,‘Kereo‘,‘Japen‘,‘Europe‘)
35     else:
36         print(‘sorry we cannot to go there‘)

2017-06-19 18:54:57


这是自己完成的第二个小编程,感觉不错!继续努力

 

多级菜单实现

标签:编程   country   log   rom   count   while   logs   贵州   back   

原文地址:http://www.cnblogs.com/zzg-home/p/7050081.html

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