Python 3.0 在Windows 命令行下输出中文

Python 3.0 中取消了 Unicode对象只保留了str,在命令行下输出中文也有所不同。

运行环境Windows XP ,Python 3.0 a1

 

 

初始代码:

print ( " 中国 " )

结果如下:

K:/work/stockget>python test1.py
  File "test1.py", line 1
SyntaxError: Non-UTF-8 code starting with '/xd6' in file test1.py on line 1, but
 no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

 

 

修改代码为:

# -*- coding: gbk -*-
print ( " 中国 " )

结果如下

K:/work/stockget>python test1.py
中国

附运行结果截图:

Python 3.0 在Windows 命令行下输出中文_第1张图片

 

 

你可能感兴趣的:(windows,python,XP,File,encoding)