它是在使用 cyryllic 时对 UnicodeDecodeError的引用。我对 Python 3.3 和 Pycharm 2.7.2 有同样的问题尝试在代码中硬编码编码,在 Pycharm 选项中手动指定编码,但没有效果。它仍然尝试使用 cp1251 库打开 utf-8 文件。
Connected to pydev debugger (build 129.314)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers\pydev\pydevd.py", line 1481, in <module>
debugger.run(setup['file'], None, None)
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers\pydev\pydevd.py", line 1124, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers\pydev\_pydev_execfile.py", line 33, in execfile
contents = stream.read()
File "C:\Python33\lib\encodings\cp1251.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 2839: character maps to <undefined>
在调试跟踪器http://youtrack.jetbrains.com/issue/PY-3669中,此问题标记为已解决,但仍存在。
有什么建议么 ?