Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")))

like image 358
mrdeadguy34 Avatar asked Oct 27 '25 14:10

mrdeadguy34


1 Answers

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).

like image 109
r.ook Avatar answered Oct 30 '25 08:10

r.ook