标签:三级菜单 占位符 没有 pre als 陌陌 int oldboy lse
#----------第三级菜单,进入后,随便输入就会退出到第三级菜单,是不是有点问题------------
data = {
‘北京‘:{
"昌平":{
"沙河":["oldboy","test"],
"天通苑":["链家地产","我爱我家"]
},
"朝阳":{
"望京":["奔驰","陌陌"],
"国贸":["CICC","HP"],
"东直门":["Advent","飞信"],
},
"海淀":{},
},
‘山东‘:{
"德州":{},
"青岛":{},
"济南":{}
},
‘广东‘:{
"东莞":{},
"常熟":{},
"佛山":{},
},
}
exit_flag = False
while not exit_flag:
for i in data:
print(i)
chioes = input(‘输入一级菜单名称:‘)
if chioes in data:
while not exit_flag:
for i2 in data[chioes]:
print(‘\t‘,i2)
chioes2 = input(‘请输入二级菜单:‘)
if chioes2 in data[chioes]:
while not exit_flag:
for i3 in data[chioes][chioes2]:
print(‘\t\t‘,i3)
chioes3 = input(‘请输入三级菜单:‘)
if chioes3 in data[chioes][chioes2]:
for i4 in data[chioes][chioes2][chioes3]:
print(‘\t\t\t‘,i4)
chioes4 = input(‘返回上一层请输入b,退出请输入q‘)
if chioes4 == ‘b‘:
pass #占位符没有意思直接略过,执行if chioes3 in data[chioes][chioes2]
elif chioes4 == ‘q‘:
exit_flag = True
if chioes3 == ‘b‘ :
break
elif chioes3 == ‘q‘:
exit_flag = True
if chioes2 == ‘b‘:
break
elif chioes2 == ‘q‘:
exit_flag = True
if chioes == ‘b‘:
break
标签:三级菜单 占位符 没有 pre als 陌陌 int oldboy lse
原文地址:https://www.cnblogs.com/yangyang---1/p/9979682.html