1python三级菜单,小白第一次随笔

Posted yangyang---1

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1python三级菜单,小白第一次随笔相关的知识,希望对你有一定的参考价值。


#----------第三级菜单,进入后,随便输入就会退出到第三级菜单,是不是有点问题------------
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(‘ ‘,i2)
chioes2 = input(‘请输入二级菜单:‘)
if chioes2 in data[chioes]:
while not exit_flag:
for i3 in data[chioes][chioes2]:
print(‘ ‘,i3)
chioes3 = input(‘请输入三级菜单:‘)
if chioes3 in data[chioes][chioes2]:
for i4 in data[chioes][chioes2][chioes3]:
print(‘ ‘,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































































以上是关于1python三级菜单,小白第一次随笔的主要内容,如果未能解决你的问题,请参考以下文章

新手小白 python之路 Day1 (三级菜单功能实现)

第一周作业-三级菜单

第一章--三级菜单作业

ComboBox,三级联动菜单,新入门点小白,有些代码有待优化,大神勿喷

Python学习_第一阶段__三级菜单

第一章练习题三级菜单