在sublime文本编辑器直接开发python程序会出现错误
Traceback (most recent call last):
File ".\sublime_plugin.py", line 337, in run_
File ".\exec.py", line 154, in run File ".\exec.py", line 45, in __init__
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xcf in position 9: ordinal not in range(128)
解决方法:
打开sublime安装目录下的sublime_plugin.py文件,在文件开头加入
reload(sys)
sys.setdefaultencoding(‘utf-8‘)
ctrl+b运行python程序,如果出现错误 [Decode error - output not utf-8],再修改Packages/Python/Python.sublime-build文件,添加字符集配置就行了("encoding": "cp936"//设置python环境的编码格式),进入目录的方法:Preference-->Brower Package 点击进入Package目录从而修改字符编码配置
时间: 2024-10-11 07:09:23