码迷,mamicode.com
首页 > 其他好文 > 详细

省市三级菜单

时间:2018-07-04 13:38:17      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:end   lag   previous   for   lse   \n   ack   any   menu   

# _*_coding:utf-8_*_
# Author:len liu



menu = {
"四川省":{
"成都市":{
"一区":["一县","二县"],
"二区":["一一县","二二县"]
},
"自贡市":{
"三区":["4县","4.5县"],
"四区":["6县","6.6县"]
} } ,
"浙江省":{
"宁波市":{
"五区":["1县","0县"],
"六区":["22县","23县"]
},
"杭州市":{
"七区":["3县","3县"],
"八区":["4县","4县"]
}},
"广东省":{
"珠海":{
"九区":["5县","6县"],
"拾区":["7县","8县"]
},
"梅州":{
"十一区":["9县","10县"],
"十二区":["11县","12县"]
}
}
}


print("show your province of china:\n")
while True:

for i in menu:
print(i)

choice = input(‘pls input which province of your choice,input "q" for exit:‘).strip()

if choice in menu:
while True:
for c in menu[choice]:
print(c)

choice2 = input(‘pls input which area of your choice or input "b" back to previous menu :‘).strip()
if choice2 in menu[choice]:
while True:
for a in menu[choice][choice2]:
print(a)
choice3 = input(‘pls input which village of your choice or input "b" back to previous menu :‘).strip()
if choice3 in menu[choice][choice2]:
for v in menu[choice][choice2][choice3]:
print(v)
choice4 = input(‘this is end of memu,input any keys back to previous menu,or input "q" exit!:‘).strip()
if choice4 == ‘q‘:
exit()
else:
pass
elif choice3 == ‘b‘:
break
elif choice2 == ‘b‘:
break
elif choice == "q":
break


省市三级菜单

标签:end   lag   previous   for   lse   \n   ack   any   menu   

原文地址:https://www.cnblogs.com/len1028/p/9262488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!