
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
pycountry-convert
Advanced tools
.. -- mode: rst --
Extension of Python package pycountry <https://pypi.python.org/pypi/pycountry>_ providing conversion functions.
.. start-badges
.. list-table:: :stub-columns: 1
* - docs
- |docs| |license|
* - info
- |hits| |contributors|
* - tests
- |travis| |coveralls|
* - package
- |version| |supported-versions|
* - other
- |requires|
.. |docs| image:: https://readthedocs.org/projects/pycountry-convert/badge/?style=flat :alt: Documentation Status :target: http://pycountry-convert.readthedocs.io
.. |hits| image:: http://hits.dwyl.io/TuneLab/pycountry-convert.svg :alt: Hits :target: http://hits.dwyl.io/TuneLab/pycountry-convert
.. |contributors| image:: https://img.shields.io/github/contributors/TuneLab/pycountry-convert.svg :alt: Contributors :target: https://github.com/TuneLab/pycountry-convert/graphs/contributors
.. |license| image:: https://img.shields.io/badge/License-MIT-yellow.svg :alt: License Status :target: https://opensource.org/licenses/MIT
.. |travis| image:: https://travis-ci.org/TuneLab/pycountry-convert.svg?branch=master :alt: Travis-CI Build Status :target: https://travis-ci.org/TuneLab/pycountry-convert
.. |coveralls| image:: https://coveralls.io/repos/TuneLab/pycountry-convert/badge.svg?branch=master&service=github :alt: Code Coverage Status :target: https://coveralls.io/r/TuneLab/pycountry-convert
.. |version| image:: https://img.shields.io/pypi/v/pycountry-convert.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/pycountry-convert
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/pycountry-convert.svg?style=flat :alt: Supported versions :target: https://pypi.python.org/pypi/pycountry-convert
.. |requires| image:: https://requires.io/github/TuneLab/pycountry-convert/requirements.svg?branch=master :alt: Requirements Status :target: https://requires.io/github/TuneLab/pycountry-convert/requirements/?branch=master
.. end-badges
.. code-block:: bash
pip install pycountry-convert
Using country data derived from wikipedia, this package provides conversion functions between ISO country names, country-codes, and continent names.
map_countries(cn_name_format="default", cn_extras={}): Return a dict of countries with key as country name (standard and official) with ISO 3166-1 values Alpha 2, Alpha 3, and Numeric. This mapping will include countries defined within pycountry, Wikipedia, and whatever extra countries provided by parameter cn_extras. Parameter cn_name_format will format the country name as request to either be using the default layout "default", lowercase "lower", or uppercase "upper".
country_alpha2_to_continent_code(): Convert country code ISO 3166-1 alpha-2 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>_ to continent name.
country_alpha2_to_country_name(cn_name_format="default"): Convert country code ISO 3166-1 alpha-2 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>_ to country name.
country_name_to_country_alpha2(cn_name, cn_name_format="default"): Convert country name to country code ISO 3166-1 alpha-2 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>_ .
country_alpha3_to_country_name(cn_name_format="default"): Convert country code ISO 3166-1 alpha-3 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3>_ to country name.
country_name_to_country_alpha3(cn_name, cn_name_format="default"): Convert country name to country code ISO 3166-1 alpha-3 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3>_ .
country_alpha3_to_country_alpha2(): Convert country code ISO 3166-1 alpha-3 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3>_ to country code ISO 3166-1 alpha-2 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>_ .
COUNTRY_NAME_FORMAT_DEFAULT "default": Country names as provide by pycountry.COUNTRY_NAME_FORMAT_LOWER "lower": All lowercase country names.COUNTRY_NAME_FORMAT_UPPER "upper": All uppercase country names.Dictionary of { cn_name: cn_alpha2_code, ... }
pycountry-convert module is built upon Python 3 and has dependencies upon
several Python modules available within Python Package Index PyPI <https://pypi.python.org/pypi>_.
pycountry <https://pypi.python.org/pypi/pycountry>_pprintpp <https://pypi.python.org/pypi/pprintpp>_.. :changelog:
FAQs
Extension of Python package pycountry providing conversion functions.
We found that pycountry-convert demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.