Python Forum

Full Version: Python 3.6.10 fails when running a localized script.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Thanks for having me here. I am a new to python.

I am stuck with something which i think most of you might already know.
I have a py script that contains some Japanese (localized) strings. When i run this script in Python.exe version 3.6.10 it throws an error like:

'SyntaxError: Non-UTF-8 code starting with '\xe5' in file (..) but no encoding declared'

Can anyone let me know how to resolve it! Think

Thanks a ton.
If the program is not encoded in UTF-8, you could add en encoding line as the first or the second line of the program, such as
# -*- coding: <encoding name> -*-
For a list of encoding names, you could list the content of the encodings directory in the python library. I don't know japanese at all but for example iso2022-jp-1 looks like a candidate for <encoding name>
@Gribouillis : That magical line helped. Thanks a ton.