1. 打開Sublime text 3 安裝package control
2. 安裝 SublimeREPL
Preferences -> package control 或者Ctrl+shift+p
鍵入 install packages稍等片刻后
鍵入 SublimeREPL 安裝即可。(由於種種原因,在國內直接通過package control安裝插件時,一定概率會出現網絡異常。可以翻牆解決,或者等網絡正常后安裝。)
3.設置安裝路徑
在 Preferences -> Package Settings -> SublimeREPL -> Settings - User里面保存自己安裝Python的路徑就好了,比如:
{ "default_extend_env": {"PATH":"C:\\python32\\"}, # 替換 "C:\\python32\\" 為自己的安裝路徑即可。 }
4.鍵位綁定
安裝完成之后,可以通過 Tools -> SublimeREPL -> Python -> Python - RUN current file 這樣的方式來啟動解釋器運行程序。或者Tools -> SublimeREPL -> Python -> Python 啟動交互式解釋器。
但是每次都這樣特別的繁瑣。最好有一個一鍵式啟動。
以下方式可以綁定 f1 鍵為交互式解釋器, f2 鍵為直接編譯當前文件。
進入Preferences -> Key Bindings-User
[ {"keys":["f1"], "caption": "SublimeREPL: Python", "command": "run_existing_window_command", "args": {"id": "repl_python", "file": "config/Python/Main.sublime-menu"}}, {"keys":["f2"], "caption": "SublimeREPL: Python - RUN current file", "command": "run_existing_window_command", "args": {"id": "repl_python_run", "file": "config/Python/Main.sublime-menu"}}, ]
5.使用
按F1鍵會出現交互式解釋器
按F2鍵虎出現執行結果
參考:1.知乎https://www.zhihu.com/question/22904994/answer/87527103