Before anyone gives me shit about this request a billion times, please note that I have tried multiple answers in many threads, but none of them seem to work properly for my problem.
import json
def parse(fn):
results = []
with open(fn) as f:
json_obj = json.loads(open(fn).read())
for r in json_obj["result"]:
print(r["name"])
parse("wine.json")
I just open the json file and repeat it for some values. Obviously, whenever I read a value with some unicode, I get this error.
Traceback (most recent call last):
File "json_test.py", line 9, in <module>
parse("wine.json")
File "json_test.py", line 7, in parse
print(r["name"])
File "C:\Python34\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u201c' in position
15: character maps to <undefined>
As people in other threads said, I tried to encode it and something else, but then I get a similar error, regardless of how I encode and / or decode it. Please, help.
source
share