I am using with open to open my json file and parse data from it, however some characters aren't ascii. I google around and found that you have to set encoding='utf8' in with open(), so I do this and get this error
UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 21: ordinal not in range(128)
So I figure I have to use ensure_ascii=False but then I get this error
TypeError: 'ensure_ascii' is an invalid keyword argument for open()
As you can see by the error ensure_ascii isn't compatible with open() but I don't know what is and I seem to be stuck and unable to find it.
The code being used
with open("languages.json", 'r', encoding='utf8') as f:
languages = json.load(f)
with open("config.json", 'r', encoding='utf8') as c:
config = json.load(c)
ensure_asciiis a param for json.ensure_asciiis a param forjson.dumpthat opposites of load, also not all json packages implement it. So it's not your case either. Try to dodata = f.read(); json.loads(data).