Awesome
country-emoji
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:
- JavaScript: country-emoji
- Swift: SwiftFlags
- Rust: country-emoji [crates.io]
PS. Happy to add more here :)
Bugs and feedback
If you discover a bug please report it here.