UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 49: character maps to <undefined>

Referenced from: https://python-forum.io/Thread-Countryinfo-package-charmap-error

from @snippsat's answer Sep-14-2018, 11:37 AM

Open countryinfo.py in ..Lib\site-packages\countryinfo folder. Change the line to:

country_info = json.load(open(file_path, encoding='utf-8'))

It works for me.


from countryinfo import CountryInfo

country = CountryInfo('Singapore')
country.capital()
# returns string
'Singapore'

country.capital() will get you the capital in a string format