Sublime报Decode error
来源:互联网 发布:linux部署nodejs项目 编辑:程序博客网 时间:2024/06/07 08:05
使用Sublime在build python程序时,有时候会遇到Decode error -output not utf-8或者是cp936。原因是python编译运行后的流的编码方式和Sublime的解码方式不同,Sublime Ctrl+B build一个python程序时,输出output not cp936,说明Sublime中的Python build默认接收的编码是cp936,如果你的python 程序是utf-8编码,有汉字输出时,Sublime就会报not cp936的错误。
如果报的是output not utf-8,说明python在编译运行源码后默认将输出结果以cp936编码发送给Sublime。而Sublime中的默认接收编码是utf-8。Sublime Text在接收到python输出后,试图以utf-8编码cp936编码的流。当cp936编码的流中没有中文字符时,用utf-8解码不会出错,当cp936编码的流中有中文字符时,因为汉子集在cp936与utf-8的编码不兼容,所以用utf-8解码就会报错。
解决问题的关键就是弄明白你的python程序的编码和Sublime的python build中指定的编码。
python sublime decode error
cp936 utf-8 output not utf-8
utf-8 cp936 output not cp936
比如,你的python代码中制定了编码格式是utf-8,现在sublime报错了output not cp936的错误,则设置Sublime中python build编码格式为utf-8,反之亦然。
Python.sublime-build 位置:
Sublime Text 2 : SublimeText2/Data/Packages/Python/ Python.sublime-build
Sublime Text 3 :SublimeText3/Packages/Python.sublime-package
或者是新建一个build文件:工具->编译系统->新建编译系统,保存为Python.sublime-build,我的文件是保存在了C:\Program Files (x86)\Sublime Text\Data\Packages\User\ 中。
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"encoding":"utf-8"
}
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"encoding":"utf-8"
}
阅读全文
0 0
- Sublime报Decode error
- Sublime Text 2报“Decode error
- Sublime python 报错 Decode error
- Python 使用 Sublime text 3 运行报错 [Decode error
- Sublime text 3 [Decode error
- Sublime Text 2报“Decode error - output not utf-8”错误的解决办法
- Sublime Text 2报“Decode error - output not utf-8”错误的解决办法
- Sublime下python 报错[Decode error - output not utf-8]解决办法
- Sublime报Decode error - output not utf-8 or cp936 错误的解决办法
- sublime :[Decode error - output not utf-8]
- 解决sublime text输出decode error问题
- 解决sublime text输出decode error问题
- python+sublime text3中文乱码[Decode error
- sublime sublime text3 提示[decode error - output not utf-8]
- Sublime text 3 [Decode error - output not utf-8]或者[Decode error - output not gbk] 解决方法
- Sublime Text: [Decode error - output not utf-8]
- sublime 出现 [Decode error - output not utf-8]
- Sublime Text 2/3 [Decode error - output not utf-8]
- HashMap源码分析
- java中使用WebView提取指定网页的HTML内容
- 自定义View一仿宝头条1号店京东垂直滚动的公告(广告)条
- Window和Linux多核多线程同步异步IPC机制
- Linux Centos下软件的安装与卸载方法
- Sublime报Decode error
- android studio导入external library
- React.js 官方文档摘记:非受控组件
- 设计模式之单例模式
- 29、不一样的C++系列--对象模型分析
- 17、java.lang.UnsatisfiedLinkError: No implementation 处理方法
- 170621
- VirtualBox 中 Ubuntu 与 Windows 共享文件夹设置
- HTML5 Canvas通过JS旋转图片