模拟三级菜单

exit_flag=False
data= {
'北京':{
"昌平":{
'沙河':['oldboy','test'],
'天通苑':['链家房产','我爱我家']
},
'朝阳':{
"望京":['奔驰','陌陌'],
'国贸':['CICC','HP'],
'东直门':{'advent','飞信'},
},
'海绽':{},
},
'山东':{
"德州":{},
'青岛':{},
'济南':{},
},
'广东': {
"东莞": {},
'常熟': {},
'佛山': {},
},
}
while not exit_flag:
for a in data:
print(a)
choice =input("请选择进入>>")
if choice in data:
while not exit_flag:
for b in data[choice]:
print('\t',b)
choice2 = input("请选择进入2>>")
if choice2 in data[choice]:
while not exit_flag:
for c in data[choice][choice2]:
print('\t\t', c)
choice3 = input("请选择进入3>>")
if choice3 in data[choice][choice2]:
while True:
for d in data[choice][choice2][choice3]:
print('\t\t', d)
choice4=input(("当前访问最后一层,输入y可返回>>"))
if choice4=='y':
break
elif choice4=='q':
exit_flag==True
if choice3=='y':
break
elif choice3=='q':
exit_flag==True
if choice2=='y':
break
elif choice2=='q':
exit_flag==True


posted @ 2018-05-29 21:26  wan了个蛋  阅读(172)  评论(0编辑  收藏  举报