Sublime文字3中的python shell

时间:2018-07-22 05:30:46

标签: python shell sublimetext3

我最近下载了Sublime Text 3,由于它没有Python Shell,因此我下载了SublimeREPL,但是每次我用SublimeREPL >>> Python >>> Python - Run current file运行代码时,输​​出后都会得到***Repl Closed***文本,阻止我与外壳交互。有没有办法解决?

1 个答案:

答案 0 :(得分:1)

不是SublimeREPL百分百相信的,但让我们直接解决问题:

找到Python配置

~/.config/sublime-text-3/Packages/SublimeREPL/config/Python/Main.sublime-menu

在此部分的python命令中添加 -i 标志(您也可以自由创建一个新标志)

{"command": "repl_open",
 "caption": "Python - RUN current file",
 "id": "repl_python_run",
 "mnemonic": "R",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",

  "cmd": ["python", “-i” ,"-u", "$file_basename"],

    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}

现在,解释器在程序完成后保持打开状态。