欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

三级菜单 python_python三级菜单

发布时间:2023/12/10 python 38 豆豆
生活随笔 收集整理的这篇文章主要介绍了 三级菜单 python_python三级菜单 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

menu = {

'北京':{

'海淀':{

'五道口':{

'soho':{},

'网易':{},

'google':{}

},

'中关村':{

'爱奇艺':{},

'汽车之家':{},

'youku':{},

},

'上地':{

'百度':{},

},

},

'昌平':{

'沙河':{

'老男孩':{},

'北航':{},

},

'天通苑':{},

'回龙观':{},

},

'朝阳':{},

'东城':{},

},

'上海':{

'闵行':{

"人民广场":{

'炸鸡店':{}

}

},

'闸北':{

'火车战':{

'携程':{}

}

},

'浦东':{},

},

'山东':{},

}

二逼青年版:while True:

for key in menu:

print(key)

choice = input(">>>:")

if len(choice) == 0: continue

if choice not in menu:continue

while True:

for key2 in menu[choice]:

print(key2)

choice2 = input(">>>:")

if len(choice2) == 0: continue

if choice2 == "b": break

if choice2 not in menu[choice]: continue

while True:

for key3 in menu[choice][choice2]:

print(key3)

choice3 = input(">>>:")

if len(choice3) == 0: continue

if choice3 == "b": break

if choice3 not in menu[choice][choice2]: continue

while True:

for key4 in menu[choice][choice2][choice3]:

print(key4)

choice4 = input(">>>:")

if len(choice4) == 0: continue

if choice4 == "b": break

if choice4 not in menu[choice][choice2][choice3]: continue

文艺青年版:current_level = menu

last_level = []

while True:

for key in current_level:

print(key)

choice = input(">>>:")

if len(choice) == 0:continue

if choice == "b":

if not last_level : break

current_level = last_level[-1]

last_level.pop()

if choice not in current_level:continue

last_level.append(current_level)

current_level = current_level[choice]

作者:terry

blog:http://www.cnblogs.com/kkterry/

Weibo:http://weibo.com/kkterry

E-mail:doubleginger@163.com

欢迎转载,还请标明出处!多谢多谢!

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:php中文网

TAG标签:python

总结

以上是生活随笔为你收集整理的三级菜单 python_python三级菜单的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。