标签:
本文主要是实现:用户交互,显示省市县三级联动的选择
代码:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author by lh
dic = {
‘河北‘: {
‘石家庄‘: [‘鹿泉‘, ‘藁城‘, ‘元氏‘],
‘邯郸‘: [‘永年‘, ‘涉县‘, ‘磁县‘],
},
‘河南‘: {
‘郑州‘:[‘中原区‘,‘二七区‘,‘金水区‘],
‘开封‘:[‘龙亭区‘,‘鼓楼区‘,‘禹王台区‘]
},
‘山西‘: {
‘太原‘:[‘迎泽区‘,‘杏花岭区‘,‘万柏林区‘ ],
‘大同‘:[‘大同县‘,‘天镇县‘,‘浑源县‘ ]
}
}
for i1 in dic:
print i1
province=raw_input(‘请输入省:‘)
a=dic[province]
for i2 in a:
print i2
city=raw_input(‘请输入市:‘)
b=a[city]
for i3 in b:
print i3
运行结果:
标签:
原文地址:http://www.cnblogs.com/pythonlh/p/5734062.html