标签:
1 menu = { 2 ‘Beijing‘: { 3 "ChaoYang": { 4 "CBD": [‘CICC‘, ‘CCTV‘], 5 "JinRongJie": ["CT"], 6 "Wangjing": ["Momo", "ChuiZI"] 7 }, 8 "HaiDian": [‘Baidu‘, ‘Youku‘] 9 }, 10 ‘Shanghai‘: { 11 "PuDong": ["Ctrip", "One Shop"], 12 "PuXi": ["China Bank", "America Bank"] 13 } 14 } 15 exit_flag = False 16 while not exit_flag: 17 for index, key in enumerate(menu.keys()): 18 print(index, key) 19 choice_1 = input("Please choose menu to enter:").strip() 20 if choice_1.isdigit(): 21 choice_1 = int(choice_1) 22 23 key_1 = list(menu.keys())[choice_1] 24 while not exit_flag: 25 for index, key in enumerate(menu[key_1]): 26 print(‘-->‘, index, key) 27 choice_2 = input("Please choose menu to enter:").strip() 28 if choice_2.isdigit(): 29 choice_2 = int(choice_2) 30 31 key_2 = list(menu[key_1].keys())[choice_2] 32 while not exit_flag: 33 for index, key in enumerate(menu[key_1][key_2]): 34 print(‘-->-->‘, index, key) 35 choice_3 = input("Please choose menu to enter:").strip() 36 if choice_3.isdigit(): 37 print("This is the last level...") 38 elif choice_3 == ‘quit‘: 39 exit_flag = True 40 elif choice_3 == ‘back‘: 41 break 42 else: 43 print("====Going to quit==== ")
注:此版本为Python3.0版本
标签:
原文地址:http://www.cnblogs.com/ouyangyixuan/p/5122518.html