- List of all countries with names and ISO 3166-1 codes in all languages and all data formats.
Install country_list by running:
pip install country_list
Get all available languages:
from country_list import available_languages
for language in available_languages():
print(language)
Get country names in english and swedish:
>>> from country_list import countries_for_language
>>> # countries_for_language returns a list of tuples now, might be changed to an OrderedDict
>>> countries = dict(countries_for_language('en'))
>>> print(countries['GB'])
'United Kingdom'
>>> print(countries['SE'])
'Sweden'
>>> countries = dict(countries_for_language('sv'))
>>> print(countries['GB'])
'Storbritannien'
>>> print(countries['SE'])
'Sverige'
Get country codes from country name:
>>> from country_list import countries_for_language
>>> # countries_for_language returns a list of tuples now, might be changed to an OrderedDict
>>> country_names = {name: code for code, name in countries_for_language('en')}
>>> print(country_names['United Kingdom'])
'GB'
>>> print(country_names['Sweden'])
'SE'
>>> country_names = {name: code for code, name in countries_for_language('sv')}
>>> print(country_names['Storbritannien'])
'GB'
>>> print(country_names['Sverige'])
'SE'
This package contains the data files from umpirsky/country-list.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
The project is licensed under the MIT license.