Skip to main content

Self-contained ISO 3166-1 country definitions.

Project description

Authors:

Mike Spindel

Version:
2.1.0

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


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.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

iso3166-2.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file iso3166-2.1.0.tar.gz.

File metadata

  • Download URL: iso3166-2.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for iso3166-2.1.0.tar.gz
Algorithm Hash digest
SHA256 c420a66a71ae18ae280342eedf4cd67aa40e83b23e36cce3e6979a2a5b79afd9
MD5 2d50aa01258b41bba6ef228683146a9e
BLAKE2b-256 e8be8fe60469a46466bb4e695d969a76b892bd9435492b5f8513408cb3c9dbfe

See more details on using hashes here.

File details

Details for the file iso3166-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: iso3166-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for iso3166-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a40f4d769b7c29aa9d73e07182fb44f29c67f63f0d7e286e2528145bdf4b3ea
MD5 071a1bd6991659eefdde0db1d0c5a403
BLAKE2b-256 fc3fc995cb300ef223d651ffdf066d06da8fcb54cec77525a140638dfb063aeb

See more details on using hashes here.

Supported by

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