标题:Sublime2 运行python3 报错output not cp936解决办法

-------------------------------------------------------------------------------------------------------------------------------

时间:2018/5/6 16:44:38

-------------------------------------------------------------------------------------------------------------------------------

内容:

Sublime中的Python build默认接收的编码是cp936,如果你的python 程序是utf-8编码,有汉字输出时,Sublime就会报not cp936的错误

解决问题的关键就是弄明白你的python程序的编码和Sublime的python  build中指定的编码。
python   sublime     decode error
cp936    utf-8         output not utf-8
utf-8      cp936       output not cp936

点击菜单的 【首选项preferences】下的【浏览插件】能找到Python.sublime-build
修改之前是
{ "cmd": ["C:/Python33/python.exe""-u""$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)""selector": "source.python" "encoding": "cp936" }

修改为
{ "cmd": ["C:/Python33/python.exe""-u""$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)""selector": "source.python" "encoding": "utf-8" }

Sublime中的Python build默认接收的编码是cp936,如果你的python 程序是utf-8编码,有汉字输出时,Sublime就会报not cp936的错误
解决问题的关键就是弄明白你的python程序的编码和Sublime的python  build中指定的编码。
python   sublime     decode error
cp936    utf-8         output not utf-8
utf-8      cp936       output not cp936

点击菜单的 【首选项preferences】下的【浏览插件】能找到Python.sublime-build
修改之前是
{ "cmd": ["C:/Python33/python.exe""-u""$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)""selector": "source.python" "encoding": "cp936" }

修改为
{ "cmd": ["C:/Python33/python.exe""-u""$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)""selector": "source.python" "encoding": "utf-8" }