Skip to main content

Pycountrycode Documentation!

What it is?

I have always loved knowing stuff. I love knowledge, it is my first love before anything else. In every kind of setup I find myself in I am always participating because I almost always have an idea about most things. This love of knowledge also made it easy for me to know more country telephone codes.

However, the truth is I couldn't cram them all the country codes and retrieve them from my mind every time it became necessary. I knew by heart those of the most popular countries that includes Russia (+7), UK (+44), USA (+1), Australia (+61) and of course Zimbabwe amongst many others.

Why?

Someone wanted to know what code +52 was for which country, I didn't know, I was embarrassed at myself. I challenged myself by writing this package so I and anyone else can use to get the country calling code of any country and also to get a country after passing in a calling code you know but are not sure about the country of origin.

Inspiration

I wanted to write something that others could find useful.

Installation

$ pip install pycountrycode

Use cases as per environment

Linux and MacOS

$ pip3 install pycountrycode
$ python3
>>> 

Windows

Windows Command Prompt
C:\Users\andil> pip install pycountrycode
C:\Users\andil> Xeroxzen> python
>>> from pycountrycode.countrycode import get_code
>>> 

Importing the 'get_code' function

>>> from pycountrycode.countrycode import get_code
>>> get_code('Zimbabwe')
'+263'
>>> get_code('New Zealand')
'+64'
>>> get_code('Peru')
'+51'
>>> get_code('Madagascar')
'+261'
>>> get_code('Russia')
'+7'
>>> get_code('Australia')
'+61'
>>> get_code('Israel')
'+972'
>>> get_code('Mal')
'Undefined country'

Importing the 'get_country' function.

>>> from pycountrycode.countrycode import get_country
>>> get_country('+52')
'Mexico' 
>>> get_country('+56')
'Easter Island'
>>> get_country('+1')
'United States of America'
>>> get_country('+7')
'Russia'
>>> get_country('+44')
'Britain'
>>> get_country('+86')
'China'
>>> get_country('+3')
'Undefined country code'
>>> get_country('+2')
'Undefined country code'
>>> get_country('+27')
'South Africa'

Library Information

>>> import pycountrycode
>>> pycountrycode.__author__
'Andile Jaden Mbele'
>>> pycountrycode.__email__
'andilembele020@gmail.com'
>>> pycountrycode.__github__
'www.github.com/xeroxzen/country-code'
>>> pycountrycode.__package__
'pycountrycode'
>>>

Also

>>> from pycountrycode.countrycode import get_code, get_country
>>> get_code('Botswana')
'+267'
>>> get_country('+33')
'France'
>>> 

Release files for pycountrycode 1.1.8

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

Source distribution (sdist)

Source distribution for pycountrycode 1.1.8
File Size Uploaded
pycountrycode-1.1.8.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycountrycode 1.1.8
File Interpreter ABI Platform
pycountrycode-1.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / pycountrycode-1.1.8.tar.gz

Download URL pycountrycode-1.1.8.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a858bb7508daa465858fe1b36eaa9ca6a1e6af2814e82bd708da6dffebfe99e5
BLAKE2b-256 checksum
How to use checksums
f0c6e9af3b0e791c26eed3bd8903b44331e3336b2a272bfcae9f6cd713bfea82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pycountrycode-1.1.8-py3-none-any.whl

Download URL pycountrycode-1.1.8-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de782cbaf8e9822c49ed1cd0e75251e9a3b2248d88a47f9511997402f1c8f721
BLAKE2b-256 checksum
How to use checksums
6d2a51e361240170832f02978e8615d9c38416c8fcb125dae5914f28cac6ca3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.1.8 This release

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

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