Skip to main content
Authors:

Mike Spindel

Version:
3.0.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'),
...

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iso3166-3.0.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iso3166-3.0.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iso3166-3.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for iso3166-3.0.0.tar.gz
Algorithm Hash digest
SHA256 e567b55d169211d4d499c73307350da15df5d38248e60bae559609570c42ef55
MD5 642f17c4fdf65c333a2ec023dc8eccfd
BLAKE2b-256 47e74997ca315143cf3dc54ec116070c108b621677fa80083a499b50643237c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iso3166-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for iso3166-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 990b1e6a433ffd89d67da8ca16f40a2af107aba1660b255a38dbd36ad221090b
MD5 ac1112ab3e71ed1a10b71447f8c5e32c
BLAKE2b-256 72998e10f81806db750ee6acf11c980207c45feddd36066cb708328e5c5aceea

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

2.1.1

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.0.1

2 files

1.0

2 files

0.9

1 file

0.8

2 files

0.7

2 files

0.6

2 files

0.5

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page