This release is a pre-release and may not be stable for production use.
countrycodes is a dependency-free Python library for looking up all 249
ISO 3166-1 countries and territories, including continent assignments and
international dial codes where available.
Installation
pip install countrycodes
Requires Python 3.11 or newer.
Usage
import countrycodes as cc
united_states = cc.get_country("us")
print(united_states.alpha3) # USA
print(united_states.numeric) # 840
print(united_states.dial_code) # +1
united_kingdom = cc.find_country("United Kingdom")
print(united_kingdom.alpha2) # GB
typo_tolerant_match = cc.find_country("Untied States")
print(typo_tolerant_match.alpha2) # US
print(len(cc.list_countries())) # 249
try:
cc.get_country("Atlantis")
except cc.CountryNotFoundError:
print("No matching country")
Lookups accept alpha-2, alpha-3, and numeric codes, dial codes, and country
names. Matching is case-insensitive and ignores surrounding or repeated
whitespace. If there is no exact match, a sufficiently similar country name
is matched as a typo-tolerant fallback. A dial code shared by multiple
countries is ambiguous and raises ValueError.
list_countries returns records sorted by alpha-2 code.
find_country returns None when there is no match; get_country raises
CountryNotFoundError. dial_code is the international country calling code,
not a local area code, and is None when no code is available.
Data and licenses
The bundled country registry is an adapted subset of ISO 3166-1 data from the
iso-codes project.
Continent assignments are from GeoNames, using
GeoNames' single-continent mapping for each country or territory. The
registry data is licensed under LGPL-2.1-or-later, continent assignments under
CC BY 4.0, and dial codes are derived from GeoNames countryInfo.txt, also
under CC BY 4.0. The library code is under BSD 3-Clause. See the
data notice,
LGPL license text,
and BSD license.
Metadata
Release files for countrycodes 0.1.0rc3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| countrycodes-0.1.0rc3.tar.gz | 23.0 kB | Without provenance | Details for countrycodes-0.1.0rc3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| countrycodes-0.1.0rc3-py3-none-any.whl | Python 3 | none | any | Details for countrycodes-0.1.0rc3-py3-none-any.whl |
Total release size: 46.7 kB
Release files / countrycodes-0.1.0rc3.tar.gz
| Download URL | countrycodes-0.1.0rc3.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a087f30a2bae6271fc90269513569472d4da8080aa49ffde14de08d46cf0dae
|
|
BLAKE2b-256 checksum How to use checksums |
66fcd6cf6feab56eaf824cd0a634be85b2933768532934be25066aa555e3ef28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / countrycodes-0.1.0rc3-py3-none-any.whl
| Download URL | countrycodes-0.1.0rc3-py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f77b74618f082a06b10425a60a5a92b8ebef0c79fcba23f601878ae79f82942
|
|
BLAKE2b-256 checksum How to use checksums |
546a507510688b847c327845210cebb31c3f5212c313a85389d11e1ed5bc1304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for countrycodes 0.1.0rc3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.