版权声明:欢迎评论交流,转载请注明原作者。 https://blog.csdn.net/m0_37809890/article/details/86747055
1. REPL环境
- 下载安装python
- 环境变量配置,直到cmd内输入python可以打开交互式解释器
- sublime安装插件SublimeREPL
- 打开sublime->preferences->Key bindings,输入
[
{
"keys": ["f5"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command",
"args": {
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"}
},
{
"keys": ["alt+f5"],
"caption": "SublimeREPL: Python - PDB current file",
"command": "run_existing_window_command",
"args": {
"id": "repl_python_pdb",
"file": "config/Python/Main.sublime-menu"}
},
{
"keys": ["f8"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command",
"args": {
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"}
},
]
现在,如果当前是一个py文件,ctrl+B是运行,F5是运行(可输入),alt+F5是调试,f8是打开交互式解释器。
2. py2和py3共存
- 配好环境变量(python.exe表示py3,python2.exe表示py2)
- 打开
C:\Users\用户名\AppData\Roaming\Sublime Text 3\Packages\User
,将以下文件保存为python_littlefall.sublime-build
; - 进入sublime,选择Tools->Build System->python_littlefall;
- 完成,按ctrl+b即可运行py文件。默认选项是python3+命令行,其它选项分别是python3+sublime,python2+命令行,python3终端,python2终端,可按ctrl+shift+b切换。
{
"encoding": "utf-8",
"working_dir": "$file_path",
"shell_cmd": "start cmd /c \" python \"$file_name\" & pause\" ",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.py",
"variants":
[
{
"name": "Run in sublime",
"shell_cmd": "python \"$file_name\""
},
{
"name": "Run with python2",
"shell_cmd": "start cmd /c \" python2 \"$file_name\" & pause\""
},
{
"name": "open python3",
"shell_cmd": "start cmd /c \" python \""
},
{
"name": "open python2",
"shell_cmd": "start cmd /c \" python2 \""
}
]
}