mrdeadguy34
mrdeadguy34

Reputation: 95

Python Reading from JSON accented characters coming out wrong

I have a string like this ("Theres loads of adventures to be had here;\nYou'll get your own Kobémon\nand get to catch more!") in my .JSON file and when I read from it into the python file and into a Tkinter textbox I get "é" instead of é. Is there a way to stop this. Im reading the .JSON using this :(self.Lines = json.load(open("Data/Lines.json")))

Upvotes: 4

Views: 4013

Answers (1)

r.ook
r.ook

Reputation: 13888

Try This:

(self.Lines = json.load(open("Data/Lines.json","rb"), encoding="utf-8"))

The difference is loading the file in bytes and reading it in utf-8 format (assuming that's the file format).

Upvotes: 10

Related Questions