Country name from ISO short code in dictionary, how to deal with non-ascii chars

2 views
Skip to first unread message

Robᵩ via StackOverflow

unread,
Sep 24, 2015, 10:29:14 PM9/24/15
to google-appengin...@googlegroups.com

If your input charset is limited to ASCII, you can still get the accents you need by using escape sequences. Try this:

import pycountry
import pprint
pprint.pprint ({country.alpha2 : country.name for country in pycountry.countries})

This produces lines like this one:

 u'CI': u"C\xf4te d'Ivoire",


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/12906090/country-name-from-iso-short-code-in-dictionary-how-to-deal-with-non-ascii-chars/32773775#32773775
Reply all
Reply to author
Forward
0 new messages