Self-contained ISO 3166-1 country definitions.
Project description
- Version:
- 2.0.2
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.2.tar.gz
(11.1 kB
view details)
Built Distribution
File details
Details for the file iso3166-2.0.2.tar.gz
.
File metadata
- Download URL: iso3166-2.0.2.tar.gz
- Upload date:
- Size: 11.1 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 | 04d02cfcfc18a6f8a9a4edb4d0a55e2e4fc575626c29d702f750de415e88d372 |
|
MD5 | a9340631612e915008fb47f51fd078d7 |
|
BLAKE2b-256 | 2c2b803db3a6e2f4041cc4e9553d3b27d81fa8938acc0ea4f86f00cc5416d5af |
File details
Details for the file iso3166-2.0.2-py3-none-any.whl
.
File metadata
- Download URL: iso3166-2.0.2-py3-none-any.whl
- Upload date:
- Size: 8.5 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 | 55e93c8a7587cae9479ad68c823390e33493d17d95b457271032594e5f1f7aae |
|
MD5 | 2ba1775abfafd27ca47778023620a220 |
|
BLAKE2b-256 | 32d81fc7d9f5b11b4490c8a9ac9fd79efb466e142468428b71dea42d5756e257 |