省市三级菜单

Posted len1028

tags:

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

# _*_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: ")
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










































































以上是关于省市三级菜单的主要内容,如果未能解决你的问题,请参考以下文章

省市三级菜单

python学习-三级菜单省市选择

省市区三级联动下拉菜单应该怎么写

layui省市区下拉菜单三级联动

asp ajax三级菜单联动国省市数据库

关于php+mysql+ajax省市区三级联动菜单,求帮助