当我在Windows中打开cmd.exe时,它使用的是什么编码?
如何查看当前使用的编码?它取决于我的区域设置还是有任何环境变量需要检查?
键入具有特定编码的文件时会发生什么?有时我会收到乱码(使用的编码不正确),有时候它会有所作为.但是,只要我不知道发生了什么,我就不相信任何事情.谁能解释一下?
我使用cmd Windows,chcp 65001,这是我的代码:
print u'\u0110 \u0110' + '\n'
Run Code Online (Sandbox Code Playgroud)
结果:
(a character cmd can't display) (character what i want)
Traceback (most recent call last):
File "b.py", line 26, in <module>
print u'\u0110 \u0110'
IOError: [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是,当我使用这段代码时:
print u' \u0110 \u0110' + '\n'
Run Code Online (Sandbox Code Playgroud)
结果:
(a space)(charecter what i want) (character what i want)
Traceback (most recent call last):
File "b.py", line 26, in <module>
print u' \u0110 \u0110' + '\n'
IOError: [Errno 2] No such file …Run Code Online (Sandbox Code Playgroud)