简体   繁体   English

在Visual Studio Code中运行Python代码?

[英]Running Python code inside Visual Studio Code?

So I've recently set up Python inside Visual Studio Code, and I use an extention called Code Runner to execute the python. 因此,我最近在Visual Studio Code中设置了Python,并使用称为Code Runner的扩展名来执行python。 The onlyproblem is, it doesn't allow input into the terminal, so if I run code that includes the input function, the whole IDE freezes, no way to get out of it or re-run the code as it says its already running, and I have to restart the IDE. 唯一的问题是,它不允许在终端中输入内容,因此,如果我运行包含input功能的代码,则整个IDE都将冻结,无法退出或重新运行已声明的代码,并且我必须重新启动IDE。

Can anyone help with this? 有人能帮忙吗?

You can go to File > Preferences -> User Settings and add this: 您可以转到文件>首选项->用户设置并添加以下内容:

    {
        "code-runner.runInTerminal": true
    }

For more information, refer to: 有关更多信息,请参阅:

https://github.com/formulahendry/vscode-code-runner/issues/91 https://github.com/formulahendry/vscode-code-runner/issues/91

Also, you can always just use the python IDE if nothing works, if it isn't a problem. 另外,如果没有问题,您也可以始终使用python IDE,如果没有问题的话。 There is another thread with python input and Visual studio here: Running python script in Visual Studio Code; 这里还有另一个带有python输入和Visual Studio的线程: 在Visual Studio Code中运行python脚本; how to get `input ()` to work? 如何使“输入()”工作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM