用户交互,显示省市县三级联动的选择。

1、用户交互,显示省市县三级联动的选择。

2、输入省份显示所有市。

3、输入市显示县。

dic = { "河北":{ "石家庄" :["鹿泉","

dic = {
    "河北":{
        "石家庄" :["鹿泉","藁城","元氏"],
        "邯郸" : ["永年","涉县","磁县"]
    },
    "河南":{
        "郑州":["巩义","登封","新密"],
        "开封":["金明","鼓楼","通许"]
    },
    "山西":{
        "太原":["古交","清徐","阳曲"],
        "大同":["天镇","阳高","广灵"]
    }
}
for i in dic.keys():
    print(i)
s = input('请选择省:')
for e in dic[s].keys():
    print(e)
e = input('请选择市:')
for y in dic[s][e]:
    print(y)

 

藁城","元氏"], "邯郸" : ["永年","涉县","磁县"] }, "河南":{ "郑州":["巩义","登封","新密"], "开封":["金明","鼓楼","通许"] }, "山西":{ "太原":["古交","清徐","阳曲"], "大同":["天镇","阳高","广灵"] } }

posted @ 2017-11-07 20:15  口水哥  阅读(688)  评论(0编辑  收藏  举报