Python 官方文档:入门教程 => 点击学习
data = {"北京":{"东城区":{"安定门":["国子监","孔庙","钟楼"],"建国门":["金宝街","长安街","西街"],"朝阳门":["东四","新街口","孚王府"],},"朝阳区":{"和平街":["顾家庄","樱
data = {
"北京":{
"东城区":{
"安定门":["国子监","孔庙","钟楼"],
"建国门":["金宝街","长安街","西街"],
"朝阳门":["东四","新街口","孚王府"],
},
"朝阳区":{
"和平街":["顾家庄","樱花社区","东街"],
"八里屯":["慈寿寺","定慧寺","前门"],
"三里屯":["夜店","工体","后海酒吧"],
},
"海淀":{
"中关村":["海龙","鼎好","科贸"],
"五道口":["清华","北大","人大"],
"航天桥":["公主坟","古城","长安街"],
},
}
}
exit_flag =False
while not exit_flag:
for i in data:
print(i)
choice = input("选择1")
if choice in data:
while not exit_flag:
for i2 in data[choice]:
print("\t",i2)
choice2 = input("选择2")
if choice2 in data[choice]:
while not exit_flag:
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\t",i4)
choice4 = input("最后一层,按b返回")
if choice4 == "b":
pass
elif choice4 == "q":
exit_flag = True
if choice3 == "b":
break
elif choice3 == "q":
exit_flag = True
if choice2 == "b":
break
elif choice2 == "q":
exit_flag = True
--结束END--
本文标题: python3 三级菜单-基础版
本文链接: https://www.lsjlt.com/news/192598.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0