測試文件hello.py:
print "你好!"
運行一般都會報錯:
File "hello.py", line 1
SyntaxError: Non-ASCII character '\xe4' in file hello.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
加上編碼注釋就能運行:
# -*- coding: utf-8 -*-
print "你好!"