Converts between country names, ISO 3166-1 codes and flag emojis. Has zero dependencies.
Inspired by JavaScript version by meeDamian
$ pip install country-emoji
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')))))) # '🇳🇿'
Check out the following:
- JavaScript: country-emoji
- Swift: SwiftFlags
- Rust: country-emoji [crates.io]
PS. Happy to add more here :)
If you discover a bug please report it here.