Home

Awesome

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.