Reputation: 2997
I get this string from the web
'Probabilità'
and I save it in a variable called temp
. Than I stored it in a dictionary
dict["key"]=temp
Then I need to write all the dictionary in a JSON file and I use this function
json_data = json.dumps(dict)
But when I look at the JSON file written by my code I see this
'Probabilit\u00e0'
How can I solve this encoding problem?
Upvotes: 0
Views: 2859
Reputation: 4812
Specify the ensure_ascii
argument in the json.dumps
call:
mydict = {}
temp = "Probabilità"
mydict["key"] = temp
json_data = json.dumps(mydict, encoding="utf-8", ensure_ascii=False)
Upvotes: 1