#belle
#三级菜单实例
menu = {
'北京':{
'海淀':{
'五道口':{
'soho':{},
'网易':{},
'google':{}
},
'中关村':{
'爱奇艺':{},
'汽车之家':{},
'youku':{},
},
'上地':{
'百度':{},
},
},
'昌平':{
'沙河':{
'老男孩':{},
'北航':{},
},
'天通苑':{},
'回龙观':{},
},
'朝阳':{},
'东城':{},
},
'上海':{
'闵行':{
"人民广场":{
'炸鸡店':{}
}
},
'闸北':{
'火车战':{
'携程':{}
}
},
'浦东':{},
},
'山东':{},
}
exit_flag = False #标志位
#current_layer = menu
#layers = [menu]
while not exit_flag:
for i in menu:#循环第一级菜单
print(i)
choice=input("选择进入>>:")#输入要进入的第一级菜单
if choice in menu:
while True:
for j in menu[choice]:
print('\t',j)
choice2 = input("选择进入>>:")#输入要进入的第二级菜单
if choice2 in menu[choice]:
while True:
for k in menu[choice][choice2]:
print('\t\t',k)
choice3 = input("选择进入>>:")#输入要进入的第三级菜单
if choice3 in menu[choice][choice2]:
for l in menu[choice][choice2][choice3]:
print('\t\t',l)
choice4=input('最后一层,输入b返回')
if choice4=='b':
# break
pass#什么都不做
elif choice4=='q':
exit_flag=True
if choice3 == 'b':
break
elif choice3 == 'q':
exit_flag = True
if choice2 == 'b':
break
elif choice2 == 'q':
exit_flag = True
python学习之路02(三级菜单实例)
猜你喜欢
转载自blog.csdn.net/bellediao/article/details/79984772
今日推荐
周排行