This will give you a list of two-digit ISO3166-1 country codes:
countries = [country.alpha2 for country in pycountry.countries]
This will give you a list of two-digit ISO639-1 language codes:
langs = [lang.iso639_1_code
for lang in pycountry.languages
if hasattr(lang, 'iso639_1_code')]
This will give you a list of all language codes:
langs = [getattr(lang, 'iso639_1_code', None) or
getattr(lang, 'iso639_2T_code', None) or
getattr(lang, 'iso639_3_code')
for lang in pycountry.languages]
Robᵩ source
share