A country code library with Chinese names based on ISO 3166
Project description
Background
In daily work, we often need to convert data exported from databases into business-friendly data for business teams. Backend data usually only contains country codes, while business users prefer to see country names.
Introduction
A Python library for ISO 3166 country code lookup with Chinese names, supporting CRUD operations.
Features
- ISO 3166-1 standard country codes
- Chinese country names
- Full CRUD support
- Lookup by alpha2, alpha3, numeric code, or Chinese name
- Lightweight, no external dependencies
Installation
pip install countryiso
Usage
Look up
import countryiso
Look up country
country = countryiso.countries.get(alpha2="CN")
print(country.chinese_name) # 中国
print(country.alpha3) # CHN
print(country.numeric) # 156
print(country.name) # China
print(country.official_name) # People's Republic of China
print(country.flag) # 🇨🇳
CRUD Example
from countryiso import Country
# Add
new_country = Country(
alpha_2="XX",
alpha_3="XXX",
name="Test Country",
chinese_name="测试国家",
numeric="999",
flag="🇽🇽"
)
countryiso.countries.add(new_country)
# Update
updated = countryiso.countries.update(new_country, chinese_name="测试国")
# Remove
countryiso.countries.remove(updated)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file countryiso-0.1.0.tar.gz.
File metadata
- Download URL: countryiso-0.1.0.tar.gz
- Upload date:
- Size: 73.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cb8a0115fd90ed8ef2cd6bb6973459f7a7adf907bd35e1e38c3316b67de3edc
|
|
| MD5 |
5bf2245f257d6e8a22329f5b906f2145
|
|
| BLAKE2b-256 |
e93923dc8416e0c1042251857856356f3c3f37d1c8b59336c22903001143242a
|
File details
Details for the file countryiso-0.1.0-py3-none-any.whl.
File metadata
- Download URL: countryiso-0.1.0-py3-none-any.whl
- Upload date:
- Size: 75.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7854d61281b43bee08bf2384329917b9bb1d039fa45f0487acdd6001090c7596
|
|
| MD5 |
9fd78afe59bcfc289844fdb569816f3f
|
|
| BLAKE2b-256 |
0ccaff327020f1fb367f5dae11dc12196dde77a499098b660dbe1dfc88927e87
|