本文介绍了Sublime开发python程序的示例代码,分享给大家,具体如下:
下载、安装Python程序
https://www.python.org/downloads/
下载、安装 sublime
关联python
Preferences->Browers Packages ->Python ->Python.sublime-build
修改Python.sublime-build文件,增加python安装路径
1
2
3
4
5
6
|
{
"cmd": ["python", "-u", "$file"],
"path":"D:\Python33",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
|
安装 Package Control
Sublime Package Control 可以说是必须安装的插件, 因为其方便的提供了安装/升级/删除 Sublime 插件的功能
用快捷键 ctrl+shift+p (Win, Linux) 或 cmd+shift+p (OS X), 其中以 Package Control: 开头的都是其相关命令, 最常用的可能就是 Package Control: Install Package, Package Control: Remove Package, Package Control: List Packages 这几个命令了.
安装步骤:view-> Show Console 菜单打开控制台 然后粘贴对应版本的代码回车
适用于 Sublime Text 3:
1
2
3
4
5
|
import urllib.request,os;
pf = 'Package Control.sublime-package' ;
ipp = sublime.installed_packages_path();
urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler()));
open (os.path.join(ipp,pf), 'wb' ).write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace( ' ' , '%20' )).read())
|
适用于 Sublime Text 2:
1
2
3
4
5
6
7
|
import urllib2,os;
pf = 'Package Control.sublime-package' ;
ipp = sublime.installed_packages_path();
os.makedirs(ipp)ifnotos.path.exists(ipp)elseNone;
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' )
|
安装插件python 代码自动补全插件(jedi)
ctrl+shift+p 打开 Package Control,然后输入Install Package回车,输入jedi
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:http://blog.csdn.net/cdl2008sky/article/details/79011894