get a china area by province, city or county
Project description
说明
一个省 -> 多个市,一个市 -> 多个县
一个县 -> 一个市, 一个市 -> 一个省
备注:县级名称单位可能会重复, 返回第一个查到的市级单位
来源:国家统计局 2017年统计用区划代码和城乡划分代码(截止2017年10月31日)
地址:http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2017/index.html
范围:省 - 市 - 县/区
快速开始
pip install chinaarea
代码示例
>>> from chinaarea import ChinaArea
# 实例化
>>> ca = ChinaArea()
# 通过省获取市
>>> ca.get_cities("山东省")
['济南市', '青岛市', '淄博市', '枣庄市', '东营市', '烟台市', '潍坊市',
'泰安市', '威海市', '日照市', '莱芜市', '临沂市', '德州市', '聊城市',
'菏泽市']
# 通过市获取县/区
>>> ca.get_counties("济南市")
['市辖区', '历下区', '市中区', '槐荫区', '天桥区', '历城区', '长清区',
'平阴县', '济阳县', '商河县', '济南高新技术产业开发区']
# 通过县获取市
>>> ca.get_city("海淀区")
'北京市'
# 通过市获取省
>>> ca.get_province("合肥市")
'安徽省'
# 判断是否是省名
>>> ca.is_province("陕西省")
>>> True
# 判断是是否是市名
>>> ca.is_city("陕西省")
>>> False
# 判断是是否是县/区名
>>> ca.is_county("南开区")
>>> True
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chinaarea-0.0.1.tar.gz
(109.8 kB
view hashes)
Built Distribution
chinaarea-0.0.1-py3-none-any.whl
(114.1 kB
view hashes)
Close
Hashes for chinaarea-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 394b4540b7218a8548f0b839971c0fa696ddc2cc9176a6816dec17f0053b6981 |
|
MD5 | cdb6225a5ce33e91e8b7dae40c1ca19c |
|
BLAKE2b-256 | 63a3feab475dda58b8b087d5c92fde2b2abe6e2a294424ced1315ecc482b15e9 |