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

三级菜单,可以退出到上一级菜单和全部退出(low版本)

时间:2017-07-13 10:47:55      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:bre   break   for   ice   输入   print   ==   inpu   网易   

menu = {
‘北京‘:{
‘海淀‘:{
‘五道口‘:{
‘soho‘:{},
‘网易‘:{},
‘google‘:{}
},
‘中关村‘:{
‘爱奇艺‘:{},
‘汽车之家‘:{},
‘youku‘:{},
},
‘上地‘:{
‘百度‘:{},
},
},
‘昌平‘:{
‘沙河‘:{
‘老男孩‘:{},
‘北航‘:{},
},
‘天通苑‘:{},
‘回龙观‘:{},
},
‘朝阳‘:{},
‘东城‘:{},
},
‘上海‘:{
‘闵行‘:{
"人民广场":{
‘炸鸡店‘:{}
}
},
‘闸北‘:{
‘火车战‘:{
‘携程‘:{}
}
},
‘浦东‘:{},
},
‘山东‘:{},
}

while True:
for key in menu:
print(key)
choice = input("请输入>>:").strip()
if len(choice) == 0:continue
if choice == "b":break
if choice == "q":exit()
if choice not in menu:continue

while True:
for key2 in menu[choice]:
print(key2)
choice2 = input("请输入>>:").strip()
if len(choice2) == 0: continue
if choice2 == "b": break
if choice2 == "q": exit()
if choice2 not in menu[choice]: continue

while True:
for key3 in menu[choice][choice2]:
print(key3)
choice3 = input("请输入>>:").strip()
if len(choice3) == 0: continue
if choice3 == "b": break
if choice3 == "q": exit()
if choice3 not in menu[choice][choice2]: continue

while True:
for key4 in menu[choice][choice2][choice3]:
print(key4)
choice4 = input("请输入>>:").strip()
if len(choice4) == 0: continue
if choice4 == "b": break
if choice4 == "q": exit()
if choice4 not in menu[choice][choice2][choice3]: continue

三级菜单,可以退出到上一级菜单和全部退出(low版本)

标签:bre   break   for   ice   输入   print   ==   inpu   网易   

原文地址:http://www.cnblogs.com/maxhaoren/p/7158494.html

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