数据齿轮 2014-10-13
这里主要解决Sublime中运行带input或raw_input的Python代码出错:EOFError: EOF when reading a line
快捷键:Ctrl+`,打开Sublime的console:
输入下面代码
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
安装sublimerepl插件
按键绑定配置加入
{ "keys": ["alt+q"], "command": "repl_open",
"caption": "Python",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-i", "-u", "$file"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python"
}
}
这样子就可以直接使用alt+q进行编译和调试。
Sublime Text 的详细介绍:请点这里
Sublime Text 的下载地址:请点这里