Skip to main content

Country-Capitals

PyPI Downloads

Get the name of a country's capital city. That's pretty much it.

Installation

pip install country_capitals

Usage

You can lookup capitals by country name, code, or ISO numbers. Including fuzzy=True will try to use use a fuzzy matching algorithm to find the country name.

from country_capitals import get_capital

get_capital("Germany")
get_capital("Germ", fuzzy=True)
get_capital("DEU")
get_capital("DE")
get_capital("276")

For ISO 3166-1 codes specifically, you can use get_capital_by_iso_code or any of the more specific functions:

from country_capitals import get_capital_by_iso_code, get_capital_by_numeric, get_capital_by_alpha2, get_capital_by_alpha3

get_capital_by_iso_code("DE")
get_capital_by_iso_code("DEU")
get_capital_by_iso_code("276")
# or
get_capital_by_alpha2("DE")
get_capital_by_alpha3("DEU")
get_capital_by_numeric("276")

Development

Run the tests:

python -m unittest

Build the package:

python -m build

Metadata

Release files for country-capitals 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for country-capitals 1.0.1
File Size Uploaded
country_capitals-1.0.1.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for country-capitals 1.0.1
File Interpreter ABI Platform
country_capitals-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / country_capitals-1.0.1.tar.gz

Download URL country_capitals-1.0.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ea76b17017ec6b0fd59d211666e538302e93ffaa03f02965fed163bd1fcca83d
BLAKE2b-256 checksum
How to use checksums
abbfadbfdb42b4c3509f337278774de9726315abc0120cf71e567f319b1f62a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.8

Release files / country_capitals-1.0.1-py3-none-any.whl

Download URL country_capitals-1.0.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
779b5ec94411ea30c0ac9dce18acb2744888522390e49b33d8b4d2d5268b048c
BLAKE2b-256 checksum
How to use checksums
40a74e056ea4c635dae9d3c4ad10bcdadca02cca19d064998766d97d37ef4aa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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