Skip to main content

A Python library to get countries, states, and cities data

Project description

Country State City Python Library

A Python library for accessing country, state, and city data.

Installation

pip install country_state_city

Usage

from country_state_city import Country, State, City

# Get all countries
countries = Country.get_countries()

# Get a country by code
usa = Country.get_country_by_code('US')
print(f"Country: {usa.name}, Flag: {usa.flag}")

# Get all states of a country
states = State.get_states_of_country('US')
for state in states[:5]:
    print(f"- {state.name} ({state.iso_code})")

# Get all cities of a state
cities = City.get_cities_of_state('US', 'CA')
print(f"Number of cities in California: {len(cities)}")

Features

  • Access to country information (name, ISO code, flag, currency, etc.)
  • Access to state/province information
  • Access to city information
  • Hierarchical relationship between countries, states, and cities
  • Timezone information for countries

Structure

  • Country class: For working with country data
  • State class: For working with state/province data
  • City class: For working with city data
  • Timezone class: For working with timezone data

License

MIT

Authors

Raymond Lucke (ray@raylucke.com)

Credits

This library is inspired by and uses data from country_state_city by Paul Pascal.

Project details


Download files

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

Source Distribution

country_state_city-0.1.0.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

country_state_city-0.1.0-py3-none-any.whl (2.8 MB view details)

Uploaded Python 3

File details

Details for the file country_state_city-0.1.0.tar.gz.

File metadata

  • Download URL: country_state_city-0.1.0.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for country_state_city-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ae055e2a3eea4dd472160435a0500c7403e2aa5236fd6f2709183d0364f16d8
MD5 cd0d28fd06c594ce0f9f76543ba12666
BLAKE2b-256 13815c89b04dc3e18f60a318a241a57bff307b53dc6b5bbc951c5d98c1c770b0

See more details on using hashes here.

File details

Details for the file country_state_city-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for country_state_city-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33cabf841e3db4aab6411ee7601133a87f7b95fe6977d13e6cb2954d3814bb6d
MD5 26335d89e54b38c1750c6c527dbc5f29
BLAKE2b-256 a0cfaa34a0e9c625c292c3c54aed9a06a37891d7f1cc797057708eaf26f8ccc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page