use*_*618 3 python encoding pycharm
我有一个仅包含的模块(这是唯一的例子.问题在于更大的模块):
# -*- coding: utf-8 -*-
"??????"
Run Code Online (Sandbox Code Playgroud)
执行时,我得到:
File "C:\Program Files\JetBrains\PyCharm 107.130\helpers\pydev\pydevd.py", line 1184, in <module>
debugger.run(setup['file'], None, None)
File "C:\Program Files\JetBrains\PyCharm 107.130\helpers\pydev\pydevd.py", line 947, in run
line = stream.readline() #Should not raise an exception even if there are no more contents
File "C:\Python32\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x83 in position 31: character maps to <undefined>
Run Code Online (Sandbox Code Playgroud)
我正在使用波兰windows xp和python 3.2.我需要更改以正确执行此模块
那个模块不是问题,它似乎是PyCharm的一个问题.它显然是读取你的文件,并假设它是cp1250,即使它被指定为utf-8.所以这是PyCharm中的一个错误.
它应该打开文件为二进制文件,读取第一行以查看它是否有编码,在其他情况下它应该假定它是UTF-8.(虽然它应该真的假设它在Python 2下是ASCII,但UTF-8足够好).
| 归档时间: |
|
| 查看次数: |
1021 次 |
| 最近记录: |