Skip to main content

中国行政区划 Python SDK

基于民政部公开数据的中国行政区划查询SDK,支持省份、城市、区县的快速查询。

安装

# pip
pip install admtp
# uv pyproject
uv add admtp
# uv pip
uv pip install admtp

快速开始

from admtp import Division
初始化
division = Division()
根据ID查询
province = division.get_province_by_id("110000") 
print(province.zh) # 北京
根据名称查询(大小写不敏感)
city = division.get_city_by_name("石家庄") 
print(city.en) # Shijiazhuang
模糊搜索
results = division.search_by_name("西安") 
for item in results: 
print(f"{item.zh} ({item.en})")

主要功能

  • ✅ 根据ID查询省市区县信息
  • ✅ 根据名称查询(支持大小写不敏感)
  • ✅ 模糊搜索行政区划
  • ✅ 获取层级关系(省->市->区县)
  • ✅ 完整的数据覆盖(包含港澳台地区)

SDK文档

Division 类

get_province_by_id(province_id)

根据省份ID获取省份信息

get_province_by_name(name)

根据省份名称获取省份信息(大小写不敏感)

get_city_by_id(city_id)

根据城市ID获取城市信息

get_city_by_name(name)

根据城市名称获取城市信息(大小写不敏感)

get_county_by_id(county_id)

根据区县ID获取区县信息

get_county_by_name(name)

根据区县名称获取区县信息(大小写不敏感)

search_by_name(name)

根据名称模糊搜索行政区划

list_provinces()

获取所有省份列表

list_cities()

获取所有城市列表

list_counties()

获取所有区县列表

get_cities_by_province(province_id)

根据省份ID获取该省的所有城市

get_counties_by_city(city_id)

根据城市ID获取该市的所有区县

许可证

Apache License 2.0

Metadata

Release files for admtp 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for admtp 1.0.1
File Size Uploaded Provenance Actions
admtp-1.0.1.tar.gz 66.5 kB Without provenance Details for admtp-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for admtp 1.0.1
File Interpreter ABI Platform Actions
admtp-1.0.1-py3-none-any.whl Python 3 none any Details for admtp-1.0.1-py3-none-any.whl

Total release size: 151.8 kB

Release files / admtp-1.0.1.tar.gz

Download URL admtp-1.0.1.tar.gz
Size 66.5 kB
Tags Source
SHA-256 checksum
How to use checksums
be46a59032372ea9332f7fbb9f8bfe0d47f3a5a0fc1d181ac6f922571dda9975
BLAKE2b-256 checksum
How to use checksums
3f417c3efa696202cef738d112b9c82996ae4c8d7c3293d240f8d25433be363c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / admtp-1.0.1-py3-none-any.whl

Download URL admtp-1.0.1-py3-none-any.whl
Size 85.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faf648627f3300c57beb3e54036b53b47bc24a665f61ae577efe8867f61a403a
BLAKE2b-256 checksum
How to use checksums
cb5b93cd0c5f837b0667658c81e7b5f0e2acadacabd9bcb17191fa67e424cc7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for admtp 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page