Skip to main content

The Python implementation for looking up the Chinese administrative divisions.

Project description

The Python implementation for looking up the Chinese administrative divisions.


$ pip install GB2260

Basic Usage

The way to look up a administrative division by its GB2260 code is the basic interface gb2260.get(code):

>>> import gb2260
>>> division = gb2260.get(360426)
>>> print(division)
<gb2260.Division 360426 江西省/九江市/德安县>

The data of a division is accessible to interfaces as following:

>>> division.code
>>> division.is_county
>>> division.is_province
>>> division.is_prefecture
>>> print(division.province)
<gb2260.Division 360000 江西省>
>>> print(division.prefecture)
<gb2260.Division 360400 江西省/九江市>
>>> print(division.county)
<gb2260.Division 360426 江西省/九江市/德安县>

The hierarchic divisions could be generated with a iterator method:

>>> division.stack()
<generator object stack at 0x103e26a50>
>>> for current in division.stack():
...     print(u'{0} {1}'.format(, current.code))
江西省 360000
九江市 360400
德安县 360426


If you want to report bugs or request features, please create issues on GitHub Issues.

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

GB2260-0.4.1.tar.gz (464.4 kB view hashes)

Uploaded source

Built Distribution

GB2260-0.4.1-py2.py3-none-any.whl (481.3 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page