Python3. The x default encoding format is UTF-8 encoded, so it can be automatically recognized for kanji characters. But for the following code containing Chinese characters, respectively, with pure txt text, geany editor, pycharm three different ways to compile the execution, only in the Pycharm can run correctly, the other two are error:
Syntaxerror:non-utf-8 code starting with ' \xb1 ' in the file demo.txt on line 1, but
No encoding declared; See http://python.org/dev/peps/pep-0263/for details
" Beijing " =print" Nanjing "print(name1,name2)
The reason for this error is that the encoding format of the Python program written in plain txt text and geany editor defaults to ASCII and gbk,python3.x the default encoding format is UTF-8, which is inconsistent. In Pycharm, the default encoding format is the UTF-8 format. If you save the txt plain text as a UTF-8 encoded format, the execution of the program is normal.
If the default file format is GBK encoded in the Geany editor preferences, it will be executed correctly after you modify it to UTF-8 format.
[Python] Python3. X encoding format problem