pycountry
pycountry copied to clipboard
Get alpha_2 with alpha_3
I currently have countries with their corresponding ISO3 code. How can I look up countries' ISO2 code with the ISO3?
what about getting the language via alpha_2 and then reading the alpha_3 attribute?
>> pycountry.languages.get(alpha_3='eng').alpha_2
'en'
@glosophy please see below code @benelgiac it is even easier than that.
>>> import pycountry
>>> alpha_3 = 'USA'
>>> country = pycountry.countries.get(alpha_3=alpha_3)
>>> country.alpha_2
'US'