【发布时间】:2015-12-09 04:38:52
【问题描述】:
我是第一次学习 Python 3 的 C 程序员。这是我的第一个脚本。
# -*- coding: utf-8 -*-
print ("Hello World!")
print ("Ä 0196, Ë 0203, Ï 0207, Ö 0214, Ü 0220, Ÿ 0159.")
这是一些设置和输出:
C:\Users\K\Desktop\Code\Python\Korgan\LearnPythonTheHardWay>chcp 65001
Active code page: 65001
C:\Users\K\Desktop\Code\Python\Korgan\LearnPythonTheHardWay>set PYTHONIOENCODING=utf-8
C:\Users\K\Desktop\Code\Python\Korgan\LearnPythonTheHardWay>py ex1.py
Hello World!
Ä 0196, Ë 0203, Ï 0207, Ö 0214, Ü 0220, Ÿ 0159.
159.
C:\Users\K\Desktop\Code\Python\Korgan\LearnPythonTheHardWay>
它打印了一个额外的“159”。最后是换行符。为什么?
'py' 不带参数:
PS C:\Users\K\desktop\code\Python\Korgan\LearnPythonTheHardWay> py
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
【问题讨论】:
-
这不是我运行你的程序时得到的结果
-
请打印以下输出:env| grep -i 编码
-
什么是“py”程序?如果你在没有参数的情况下运行“py”会发生什么?
-
@fiacre 不幸的是,这是在win8上。
-
@fiacre 我已经更新了我的问题以显示没有参数的“py”。
标签: python unicode utf-8 codepages