老男孩培训学习:
1 ‘‘‘ 2 Author:Ranxf 3 ‘‘‘ 4 menu = { 5 ‘北京‘: { 6 ‘海淀‘: { 7 ‘五道口‘: { 8 ‘soho‘: {}, 9 ‘网易‘: {}, 10 ‘google‘: {} 11 }, 12 ‘中关村‘: { 13 ‘爱奇艺‘: {}, 14 ‘汽车之家‘: {}, 15 ‘youku‘: {}, 16 }, 17 ‘上地‘: { 18 ‘百度‘: {}, 19 }, 20 }, 21 ‘昌平‘: { 22 ‘沙河‘: { 23 ‘老男孩‘: {}, 24 ‘北航‘: {}, 25 }, 26 ‘天通苑‘: {}, 27 ‘回龙观‘: {}, 28 }, 29 ‘朝阳‘: {}, 30 ‘东城‘: {}, 31 }, 32 ‘上海‘: { 33 ‘闵行‘: { 34 "人民广场": { 35 ‘炸鸡店‘: {} 36 } 37 }, 38 ‘闸北‘: { 39 ‘火车战‘: { 40 ‘携程‘: {} 41 } 42 }, 43 ‘浦东‘: {}, 44 }, 45 ‘山东‘: {}, 46 } 47 exit_flag = False 48 49 while not exit_flag: 50 for i1 in menu: 51 print(i1) 52 53 choice1 = input(">>>选择一级菜单1>>>: ") 54 if choice1 in menu: 55 while not exit_flag: 56 for i2 in menu[choice1]: 57 print("\t", i2) 58 59 choice2 = input(">>>选择二级菜单2>>>: ") 60 if choice2 in menu[choice1]: 61 while not exit_flag: 62 for i3 in menu[choice1][choice2]: 63 print("\t\t", i3) 64 65 choice3 = input(">>>选择三级菜单3>>>: ") 66 if choice3 in menu[choice1][choice2]: 67 for i4 in menu[choice1][choice2][choice3]: 68 print("\t\t", i4) 69 choice4 = input(">>>最后一级菜单,按b返回,按q退出>>>: ") 70 if choice4 == ‘b‘: 71 pass 72 elif choice1 == ‘q‘: 73 exit_flag = True 74 75 if choice3 == ‘b‘: 76 break 77 elif choice3 == ‘q‘: 78 exit_flag = True 79 80 if choice2 == ‘b‘: 81 break 82 elif choice2 == ‘q‘: 83 exit_flag = True 84 if choice1 == ‘b‘: 85 break 86 elif choice1 == ‘q‘: 87 exit_flag = True
原文地址:https://www.cnblogs.com/ranxf/p/8275373.html
时间: 2024-10-04 10:32:28