Sublime text 3 - Python获取input的方法

Sublime Text3编写Python代码很方便,但是自带的Python编译方式无法获取input()函数的内容,为此,有2种方法可以获取input输入。一种是使用Windows自带的cmd命令行运行Python程序;另一种是使用插件SublimeREPL运行程序。

1 cmd命令行

打开sublime->tool->build system->build new system,添加下面的内容,并保存为Python37

{
    "encoding": "utf-8",
    "working_dir": "$file_path",
    "shell_cmd": "python.exe -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "variants":
    [
        {
            "name" :"RunInCmd",
            "shell" :true,
            "shell_cmd":"start cmd /c \" python \"$file\" & pause\""
        }

    ]
}

2 安装插件SublimeREPL

  1. 使用快捷键CTRL+SHIFT+P,打开Package Control,选择SublimeREPL进行安装。

  2. 使用工具Tools-> SublimeREPL->Python->Python-RUN current file运行代码即可获取input输入。

  3. 使用快捷键简化操作流程,方法如下:

    • 选择Sublime Text 3-> 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"}
      
            }
        ]
      

其它

编译C/C++语言请参考<Sublime Text 3直接编译执行C/C++程序>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值