>>> import sys
>>> sys.path.append("c:\\")
>>> import chinese
中文
一切都很完美!
再试试其它编码,把chinese.py的文件编码改成gbk,再执行上面的操作,结果报错:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import chinese
File "c:\chinese.py", line 1
SyntaxError: Non-UTF-8 code starting with '\xd6' in file c:\chinese.py on line 1,
but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details