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.

Installation

$ 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
u'360426'
>>> division.name
u'德安县'
>>> division.is_county
True
>>> division.is_province
False
>>> division.is_prefecture
False
>>> 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.name, current.code))
江西省 360000
九江市 360400
德安县 360426

Issues

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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file GB2260-0.4.1.tar.gz.

File metadata

  • Download URL: GB2260-0.4.1.tar.gz
  • Upload date:
  • Size: 464.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for GB2260-0.4.1.tar.gz
Algorithm Hash digest
SHA256 b7b31c1549e53b7b8c517ca793c1395fae9c0c81cb2158b7ff4b61bee7d42546
MD5 48eb3abe916875702893cefa33de2715
BLAKE2b-256 ca014b1a1a593fbe8dcc016f3eddab7978801b7c4bd328077200c4cd430072b7

See more details on using hashes here.

Provenance

File details

Details for the file GB2260-0.4.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for GB2260-0.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7708e26955a09b647d4f2d263961df763e97d6f98790921defbb190745342f10
MD5 84cda3faa469e2b4df578124f506c846
BLAKE2b-256 136669a0545ed97d3689ff422a2504ff51a298a78b4795fe05228ef944bc22f2

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page