Python output "Hello, world!", English no problem, but if you output Chinese characters "Hello, the World" may encounter Chinese encoding problem.
If no encoding is specified in the Python file, an error occurs during execution:
#!/usr/bin/pythonprint "Hello, World";
The above program execution output results are:
File "test.py", line 2syntaxerror:non-ascii character ' \xe4 ' in file test.py on line 2, but no encoding declared; See http://www.python.org/peps/pep-0263.html for details
The default encoding format in Python is the ASCII format, which fails to print correctly when the encoding format is not modified, so the error occurs when reading Chinese.
The workaround is to add #-*-Coding:utf-8-*-or #coding =utf-8 at the beginning of the file.
Instance (Python 2.0+)
#!/usr/bin/python#-*-coding:utf-8-*-print "Hello, World";
The output is:
Hello, world
So if you re-learn the process, the code contains Chinese, you need to specify the coding in the head.
Note: The python3.x source file uses Utf-8 encoding by default, so the Chinese can be parsed normally without specifying UTF-8 encoding.