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.
External Links
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.1.0.tar.gz
(30.9 kB
view details)
Built Distributions
GB2260-0.1.0-py3-none-any.whl
(32.8 kB
view details)
GB2260-0.1.0-py2-none-any.whl
(32.8 kB
view details)
File details
Details for the file GB2260-0.1.0.tar.gz
.
File metadata
- Download URL: GB2260-0.1.0.tar.gz
- Upload date:
- Size: 30.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc2dc7e0f497638f5715ba33bb59ca9303e42f332d0626922fc7f11c1e0e6e31 |
|
MD5 | 0e9ffa01929256866944bf8ddc6574f9 |
|
BLAKE2b-256 | 71ad60c4fd509a3c0e8da7136bc96bb2a07d8d982fd6de4f74eb1a071bb4290f |
Provenance
File details
Details for the file GB2260-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: GB2260-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676a42b379c3019567e59f561b1561b824f991d2f61e327cc606b350195f86ca |
|
MD5 | c5bcc68fdb2569593aea9ad0d799bebe |
|
BLAKE2b-256 | a4749718380f325d233f6cc081e67e6f93c7617901c11ff31e8f1b5780dbc894 |
Provenance
File details
Details for the file GB2260-0.1.0-py2-none-any.whl
.
File metadata
- Download URL: GB2260-0.1.0-py2-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5312d85e4b9816519bd4236a30f965b38d911869ae5ed92a731b617d6d32f652 |
|
MD5 | 6eba14b906a9824703613d0cbb494da0 |
|
BLAKE2b-256 | 55c1773825f61cbd3dbc484b2ac6f27ca6c7633ee6fdf337385e89d8818ff8a2 |