时间:2020-10-04 14:43:53 | 栏目:Python代码 | 点击:次
本文介绍了Sublime开发python程序的示例代码,分享给大家,具体如下:
下载、安装Python程序
https://www.python.org/downloads/
下载、安装 sublime
关联python
Preferences->Browers Packages ->Python ->Python.sublime-build
修改Python.sublime-build文件,增加python安装路径
{ "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:
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:
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