Skip to main content

Self-contained ISO 3166-1 country definitions.

Project description

Authors:

Mike Spindel

Version:
1.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=u'United States', alpha2='US', alpha3='USA', numeric='840')
>>> countries.get('ala')
Country(name=u'\xc5land Islands', alpha2='AX', alpha3='ALA', numeric='248')
>>> countries.get(8)
Country(name=u'Albania', alpha2='AL', alpha3='ALB', numeric='008')

Country lists and indexes

>>> from iso3166 import countries

>>> for c in countries:
       print c
>>> Country(name=u'Afghanistan', alpha2='AF', alpha3='AFG', numeric='004')
Country(name=u'\xc5land Islands', alpha2='AX', alpha3='ALA', numeric='248')
Country(name=u'Albania', alpha2='AL', alpha3='ALB', numeric='008')
Country(name=u'Algeria', alpha2='DZ', alpha3='DZA', numeric='012')
>>> import iso3166

>>> iso3166.countries_by_name
>>> {u'AFGHANISTAN': Country(name=u'Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'),
u'ALBANIA': Country(name=u'Albania', alpha2='AL', alpha3='ALB', numeric='008'),
u'ALGERIA': Country(name=u'Algeria', alpha2='DZ', alpha3='DZA', numeric='012'),
...

>>> iso3166.countries_by_numeric
>>> {'004': Country(name=u'Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'),
'008': Country(name=u'Albania', alpha2='AL', alpha3='ALB', numeric='008'),
'010': Country(name=u'Antarctica', alpha2='AQ', alpha3='ATA', numeric='010'),
...

>>> iso3166.countries_by_alpha2
>>> {'AD': Country(name=u'Andorra', alpha2='AD', alpha3='AND', numeric='020'),
'AE': Country(name=u'United Arab Emirates', alpha2='AE', alpha3='ARE', numeric='784'),
'AF': Country(name=u'Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'),
...

>>> iso3166.countries_by_alpha3
>>> {'ABW': Country(name=u'Aruba', alpha2='AW', alpha3='ABW', numeric='533'),
'AFG': Country(name=u'Afghanistan', alpha2='AF', alpha3='AFG', numeric='004'),
'AGO': Country(name=u'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-1.0.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

iso3166-1.0.1-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: iso3166-1.0.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9

File hashes

Hashes for iso3166-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b1e58dbcf50fbb2c9c418ec7a6057f0cdb30b8f822ac852f72e71ba769dae8c5
MD5 53c313c7ae8721e40ddd5e7a01bbcb7e
BLAKE2b-256 5b62b0f573e5d9ea128084f2440924e95f4e54690ccee9d974b5bf345e5f8540

See more details on using hashes here.

File details

Details for the file iso3166-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: iso3166-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9

File hashes

Hashes for iso3166-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b07208703bd881a4f974e39fa013c4498dddd64913ada15f24be75d02ae68a44
MD5 5aa787864d33d0a41a33e69b0bad86b2
BLAKE2b-256 a04215d2ef2211ddb26deb810a21b084ee6f3d1bc7248e884dcabb5edc04b649

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