三层菜单1

匿名 (未验证) 提交于 2019-12-03 00:03:02

打印省、市、县三级菜单

可返回上一级

可随时退出程序

menu = {
'北京':{
'海淀':{
'清华':{},
'北大':{}
},
'昌平':{
'沙河':{},
'天通苑':{},
'回龙观':{}
}
},
'上海':{
'闵行':{
'上海发电机厂':{},
'上海汽轮机厂':{},
'上海锅炉厂':{}
},
'松江':{
'东华大学':{
'教学楼':{},
'食堂':{},
'图书馆':{},
'宿舍':{}
},
'上海外国语大学':{},
'华东政法大学':{}
},
'徐汇':{
'百脑汇':{},
'上海交通大学':{},
'铁山家':{}
}
},
'辽宁':{
'沈阳':{
'王寅':{},
'ܼܼ':{},
'铁西':{}
},
'大连':{
'大连交通大学':{},
'大连医科大学':{}
},
'朝阳':{
'二高':{},
'四中':{},
'板面':{},
'灌汤包':{},
'炖肠':{}
}
}
}

switch = True
while switch:
menu1 = menu

for key in menu1:     print(key) print('import back to last step,quit to end or choice to next step:')  choice1 = input('1 step:').strip()  if choice1 == 'back':     break if choice1 == 'quit':     switch = False     break if choice1 not in menu1:     continue  while switch:     menu2 = menu1[choice1]      for key in menu2:         print(key)     print('import back to last step,quit to end or choice to next step:')      choice2 = input('2 step:').strip()       if choice2 == 'back':         break     if choice2 == 'quit':         switch = False         break     if choice2 not in menu2:         continue      while switch:         menu3 = menu2[choice2]          for key in menu3:             print(key)          print('import back to last step,quit to end or choice to next step:')          choice3 = input('2 step:').strip()          if choice3 == 'back':             break         if choice3 == 'quit':             switch = False             break         if choice3 not in menu3:             continue
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!