VSC for Python 中的 CodeRunner 设置 [英] CodeRunner Setup in VSC for Python

查看:51
本文介绍了VSC for Python 中的 CodeRunner 设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 VSC 并向其中添加了 C/C++ 和 CodeRunner 扩展,并且一切正常.我已将 CodeRunner 设置为在终端中运行,但我没有对设置进行太多其他设置.

I've installed VSC and added to it the C/C++ and CodeRunner extensions, and it all worked perfectly. I've set CodeRunner to run in Terminal and I haven't done much else to the settings.

但是,我现在安装了 Python 扩展,单击 CodeRunner 的运行"按钮时会显示 2 个选项:在终端中运行代码和运行 Python 文件.以前运行 C 程序时,单击运行"即可.

However, I installed the Python extension now, and the CodeRunner 'Run' button displays 2 options when I click it: Run Code and Run Python File in Terminal. When I was running a C program previously, one click on 'Run' would do it.

有什么办法可以消除运行 Python 代码时的额外选项?本质上,我只希望通过单击运行"来执行程序.似乎无论我选择哪个选项,代码都会执行.(见附图).谢谢.

Is there any way to eliminate the extra options when running Python code? Essentially, I just want the program to execute with one click on 'Run'. Seems like the code executes regardless of the option I choose. (See the attached picture). Thank you.

推荐答案

  1. 原因:在 VS Code 中,Python"提供的绿色运行按钮扩展是执行命令Run Python File in Terminal".在VS Code的Terminal中,我们只需要点击一次就可以运行python文件:

  1. Reason: In VS Code, the green run button provided by the "Python" extension is to execute the command "Run Python File in Terminal". It only requires us to click once to run python files in the Terminal of VS Code:

当我们还使用扩展Code Runner"时,它提供的运行按钮(Run Code")默认在OUTPUT"中输出结果.在之前的使用中,这个按钮会覆盖python"提供的绿色按钮.扩展,但现在它们是集成的,我们可以选择执行方式.

When we also use the extension "Code Runner", the run button ("Run Code") provided by it defaults to output results in "OUTPUT". In the previous use, this button will cover the green button provided by the "python" extension, but now that they are integrated, we can choose the execution method.

对于设置code-runner.runInTerminal":false,它决定了code runner"是否被设置为false.在终端"中运行,它们执行的命令是不同的:

For setting "code-runner.runInTerminal": false, it determines whether the "code runner" runs in the "Terminal", the commands they execute are different:

"运行代码":python -u "/python_file.py"

在终端中运行 Python 文件":/python.exe/python_file.py

解决方案:您可以使用 F5 来调试代码或尝试关闭Code Runner".延期.(单击Enable"以恢复扩展程序的使用.)

Solution: You could use F5 to debug the code or try to close the "Code Runner" extension. (Click "Enable" to restore the use of the extension.)

参考:在 VS Code 中运行 Python 文件.

这篇关于VSC for Python 中的 CodeRunner 设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆