Self-contained ISO 3166-1 country definitions.
Project description
- Version:
- 2.0.1
ISO 3166-1 defines two-letter, three-letter, and three-digit country codes. python-iso3166 is a self-contained module that converts between these codes and the corresponding country name.
Installation
$ pip install iso3166
Usage
Country details
>>> from iso3166 import countries >>> >>> countries.get('us') Country(name='United States', alpha2='US', alpha3='USA', numeric='840') >>> countries.get('ala') Country(name='Åland Islands', alpha2='AX', alpha3='ALA', numeric='248') >>> countries.get(8) Country(name='Albania', alpha2='AL', alpha3='ALB', numeric='008')
Country lists and indexes
>>> from iso3166 import countries >>> for c in countries: print(c) >>> Country(name='Afghanistan', alpha2='AF', alpha3='AFG', numeric='004') Country(name='Åland Islands', alpha2='AX', alpha3='ALA', numeric='248') Country(name='Albania', alpha2='AL', alpha3='ALB', numeric='008') Country(name='Algeria', alpha2='DZ', alpha3='DZA', numeric='012')
>>> import iso3166 >>> iso3166.countries_by_name >>> {'AFGHANISTAN': Country(name='Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'), 'ALBANIA': Country(name='Albania', alpha2='AL', alpha3='ALB', numeric='008'), 'ALGERIA': Country(name='Algeria', alpha2='DZ', alpha3='DZA', numeric='012'), ... >>> iso3166.countries_by_numeric >>> {'004': Country(name='Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'), '008': Country(name='Albania', alpha2='AL', alpha3='ALB', numeric='008'), '010': Country(name='Antarctica', alpha2='AQ', alpha3='ATA', numeric='010'), ... >>> iso3166.countries_by_alpha2 >>> {'AD': Country(name='Andorra', alpha2='AD', alpha3='AND', numeric='020'), 'AE': Country(name='United Arab Emirates', alpha2='AE', alpha3='ARE', numeric='784'), 'AF': Country(name='Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'), ... >>> iso3166.countries_by_alpha3 >>> {'ABW': Country(name='Aruba', alpha2='AW', alpha3='ABW', numeric='533'), 'AFG': Country(name='Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'), 'AGO': Country(name='Angola', alpha2='AO', alpha3='AGO', numeric='024'), ...
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
iso3166-2.0.1.tar.gz
(10.9 kB
view details)
Built Distribution
File details
Details for the file iso3166-2.0.1.tar.gz
.
File metadata
- Download URL: iso3166-2.0.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 280fb86d9908f2cbfcbb5f155ed45dfd963e8e9856d902c41f46f63d64f9f639 |
|
MD5 | ae66ecf6e83404485f9586f325c896ee |
|
BLAKE2b-256 | 59d71f875a69b9b2ba2158a860f674725df7a2917c112a47223da92b756c3214 |
File details
Details for the file iso3166-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: iso3166-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 254861371e597fc65b3a508be568fc1a89c966fc183a9d5d86f95598a2fa9e2f |
|
MD5 | 13df6e90f318b5c16ac4062fc67e44a4 |
|
BLAKE2b-256 | d7e56dde55eb412cad6729c63835f641fe386b5cb6edd9b0e06ee0a45ee4c302 |