python修行之路(六 三级菜单实例)
三級菜單實例:
?
menu = {
??? '北京':{
??????? '海淀':{
??????????? '五道口':{
??????????????? 'soho':{},
??????????????? '網易':{},
??????????????? 'google':{}
??????????? },
??????????? '中關村':{
??????????????? '愛奇藝':{},
??????????????? '汽車之家':{},
??????????????? 'youku':{},
??????????? },
??????????? '上地':{
??????????????? '百度':{},
??????????? },
??????? },
??????? '昌平':{
??????????? '沙河':{
??????????????? '老男孩':{},
??????????????? '北航':{},
??????????? },
??????????? '天通苑':{},
??????????? '回龍觀':{},
??????? },
??????? '朝陽':{},
??????? '東城':{},
??? },
??? '上海':{
??????? '閔行':{
??????????? "人民廣場":{
??????????????? '炸雞店':{}
??????????? }
??????? },
??????? '閘北':{
??????????? '火車戰':{
??????????????? '攜程':{}
??????????? }
??????? },
??????? '浦東':{},
??? },
??? '山東':{},
}
while True:
for i in data:
print(i)
choice = input("選擇進入:")
if choice in data:
while True:
for i2 in data[choice]:
print ("\t",i2)
choice2 = input("選擇進入2>>:")
if i2 in data[choice]:
while True:
for i3 in data[choice ][choice2]:
print("\t\t",i3)
choice3 = input("選擇進入3>>:")
if choice3 in data[choice][choice2]:
for i4 in data[choice][choice2][choice3]:
print("\t\t",i4)
choice4 = input("最后一層,按b返回>>:")
if choice4 == "b":
pass
if choice3 == "b":
break
if choice2 =="b":
break
轉載于:https://www.cnblogs.com/ysw-1990/p/6802730.html
總結
以上是生活随笔為你收集整理的python修行之路(六 三级菜单实例)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux 下查看某一个程序所使用的内存
- 下一篇: websocket python爬虫_p