Skip to content

Converts between country names, ISO 3166-1 codes and flag emojis.

License

Notifications You must be signed in to change notification settings

Nnonexistent/country-emoji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

country-emoji

GA test PyPI License PyPI - Format

Converts between country names, ISO 3166-1 codes and flag emojis. Has zero dependencies.

Inspired by JavaScript version by meeDamian

Install

$ pip install country-emoji

Usage

import country_emoji as ce

ce.flag('CL')  # '🇨🇱'

ce.code('🇨🇦')  # 'CA'

ce.name('🇶🇦')  # 'Qatar'

# can extract name from string...
ce.flag('Taiwan number one!')  # '🇹🇼'

# ...but only if there's no ambiguity
ce.flag('Congo and Burma')  # ''

ce.flag('Republic of Tanzania')  # '🇹🇿'

ce.flag('Tanzania, United Republic of')  # '🇹🇿'

ce.code('Australia')  # 'AU'

ce.code('UAE')  # 'AE'

ce.name('AE')  # 'United Arab Emirates'

ce.code('UK')  # 'GB'

# all values can be converted back and forth indefinitely
ce.flag(ce.name(ce.flag(ce.code(ce.flag(ce.name('NZ'))))))  # '🇳🇿'

Don't want Python?

Check out the following:

PS. Happy to add more here :)

Bugs and feedback

If you discover a bug please report it here.

About

Converts between country names, ISO 3166-1 codes and flag emojis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages