Skip to content

Latest commit

 

History

History
62 lines (38 loc) · 1.79 KB

README.md

File metadata and controls

62 lines (38 loc) · 1.79 KB

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.