代码:
'''
print('中文') '''
报错:
''' File "C:\Users\Cstome\AppData\Local\Programs\Python\Python35\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 85-90: character maps to <undefined> '''
local 切换成简体中文就好了,但除此之外还有其他方法吗?
1
billlee 2017-03-31 00:27:46 +08:00
The character encoding is platform-dependent. Under Windows, if the stream is interactive (that is, if its isatty() method returns True), the console codepage is used, otherwise the ANSI code page. Under other platforms, the locale encoding is used (see locale.getpreferredencoding()).
Under all platforms though, you can override this value by setting the PYTHONIOENCODING environment variable before starting Python. 所以,试试启动 python 前 chcp 65001 |