PyPI
pypi.org › project › pycountry
pycountry · PyPI
>>> germany = pycountry.countries.get(alpha_2='DE') >>> germany Country(alpha_2='DE', alpha_3='DEU', flag='🇩🇪', name='Germany', numeric='276', official_name='Federal Republic of Germany') >>> germany.alpha_2 'DE' >>> germany.alpha_3 'DEU' >>> germany.numeric '276' >>> germany.name 'Germany' >>> germany.official_name 'Federal Republic of Germany'
» pip install pycountry
Published Feb 17, 2026
Version 26.2.16
Anaconda.org
anaconda.org › conda-forge › pycountry
pycountry - conda-forge | Anaconda.org
GitHub Repository https://github.com/flyingcircusio/pycountry · Documentation https://pypi.org/project/pycountry/
Readthedocs
pycountry-convert.readthedocs.io › en › latest
pycountry-convert — pycountry-convert 0.7.3 documentation
Extension of Python package pycountry providing conversion functions.
GitHub
github.com › pycountry › pycountry
GitHub - pycountry/pycountry: A Python library to access ISO country, subdivision, language, currency and script definitions and their translations. · GitHub
A Python library to access ISO country, subdivision, language, currency and script definitions and their translations. - pycountry/pycountry
Starred by 964 users
Forked by 140 users
Languages Python 90.8% | Makefile 8.9% | Nix 0.3%
Messageix
docs.messageix.org › projects › models › en › latest › _modules › message_ix_models › util › pycountry.html
message_ix_models.util.pycountry — message-ix-models documentation
Returns ------- str or None """ from pycountry import countries, historic_countries # Maybe map a known, non-standard value to a standard value name = COUNTRY_NAME.get(name, name) # Use pycountry's built-in, case-insensitive lookup on all fields including name, # official_name, and common_name for db in (countries, historic_countries): try: return db.lookup(name).alpha_3 except LookupError: continue # Not found in `db`, e.g.
Read the Docs
app.readthedocs.org › projects › pycountry-convert › downloads › pdf › latest pdf
pycountry-convert Documentation Release 0.7.3 TUNE Inc. May 31, 2018
May 31, 2018 - Extension of Python package pycountry providing conversion functions.
GitHub
github.com › PEAT-AI › pycountry
GitHub - PEAT-AI/pycountry
Countries (ISO 3166) ==================== Countries are accessible through a database object that is already configured upon import of pycountry and works as an iterable: >>> import pycountry >>> len(pycountry.countries) 249 >>> list(pycountry.countries)[0] Country(alpha_2='AF', alpha_3='AFG', name='Afghanistan', numeric='004', official_name='Islamic Republic of Afghanistan') Specific countries can be looked up by their various codes and provide the information included in the standard as attributes: >>> germany = pycountry.countries.get(alpha_2='DE') >>> germany Country(alpha_2='DE', alpha_3=
Author PEAT-AI
CloudDefense.ai
clouddefense.ai › code › python › example › pycountry
Top 10 Examples of <!-- -->pycountry<!-- --> code in Python | CloudDefense.AI
def __determine_iso_639_3_key(): """ Determine the key needed for accessing ISO 639-3 language codes using pycountry. """ # Different version of pycountry seem to use different keys.
Snyk
snyk.io › advisor › pycountry › functions › pycountry.countries.get
How to use the pycountry.countries.get function in pycountry | Snyk
if airport_type != 'large_airport' and airport_type != 'small_airport' and airport_type != 'medium_airport': continue airport_type = airport_type.split("_")[0] airport_name = row['name'].strip() airport_coords = { 'lat': float(row['latitude_deg']), 'lon': float(row['longitude_deg']) } airport_city = row['municipality'].strip() airport_url = row['home_link'].strip() airport_wiki = row['wikipedia_link'].strip() airport_icao = row['ident'].upper().strip() # Add a '.' after single uppercase letters airport_name = re.sub( r"\b([A-Z])(?![\w\-\.])", r"\1.", airport_name) country_iso_code = row['iso_c
Iiasa
docs.ece.iiasa.ac.at › standards › countries.html
A common list of country names — ece-docs documentation
The nomenclature package (read the docs) builds on the pycountry package to provide a standardized list of country names based on the ISO 3166-1 standard.
Snyk
snyk.io › advisor › pycountry › functions › pycountry.languages
How to use the pycountry.languages function in pycountry | Snyk
rlz_pointer = 8 # Examples of longer RLZ values (2- and 5-char lang codes): # 1C1CHBF_en-GBGB901GB901 # 1C1GCEU_enUS820US820 if len(rlz_string) >= 11: # If a dash is in this position, it means it is a 5 char lang code, not the 2 char code if rlz_string[10] == '-': language_code = rlz_string[rlz_pointer:rlz_pointer+5] rlz_pointer += 5 # langcodes was having install issues on macOS; not using it for now in # order to not complicate Unfurl's install. Pycountry's languages isn't # as good (only alpha_2 and alpha_3) but better than nothing for now.
GitHub
github.com › pycountry › pycountry › issues
Issues · pycountry/pycountry
A Python library to access ISO country, subdivision, language, currency and script definitions and their translations. - Issues · pycountry/pycountry
Author pycountry
GitHub
github.com › koldakov › pycountries
GitHub - koldakov/pycountries: Python library to access ISO country and currency standards. · GitHub
from decimal import Decimal from fastapi import FastAPI from pycountries import Country, Currency, Language from pydantic import BaseModel, model_validator app = FastAPI() class IndexRequest(BaseModel): country: Country currency: Currency amount: Decimal language: Language @model_validator(mode="after") def validate_amount(self) -> "IndexRequest": # TODO: Keep in mind, you need to handle exceptions raised by clean_amount method, # otherwise Internal Server Error will be raised.
Author koldakov
Top answer 1 of 2
8
import pycountry
user_input = raw_input(': ')
mapping = {country.name: country.alpha_2 for country in pycountry.countries}
print mapping.get(user_input)
is the correct way you are using 'alpha2' instead of alpha_2
2 of 2
2
For Python3, I believe that using the Pytz built-in module will be easier
>> import pytz
>> print(pytz.country_names['tn'])
Tunisia