多級菜單實現
阿新 • • 發佈:2017-06-19
lis ict while log 廣西 自己 天津 please cnblogs
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
這是自己完成的第二個小編程,感覺不錯!繼續努力
多級菜單實現