为什么当我执行Python时Code Runner总是在VSCode中打开其他终端?以及如何解决?

问题描述 投票:0回答:2

即使已经打开了一个终端,当我使用

Python
(
Code Runner
) 运行
ctrl + alt + n
代码时,在 VSCode 中它总是会打开另一个终端。关闭旧的也没有用,因为它会再次打开。

enter image description here

这是我的终端、Python 和 Code Runner 的配置:

终端:

"terminal.integrated.copyOnSelection": true,
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.letterSpacing": 1,

代码运行者:

"code-runner.clearPreviousOutput": true,
"code-runner.saveAllFilesBeforeRun": true,
"code-runner.ignoreSelection": true,
"code-runner.runInTerminal": true, //only 2 Python
"code-runner.executorMap": {
    "javascript": "node",

    "python": "venv\\Scripts\\python.exe -u", //code-runner exec python of venv
    "bat": "cmd /c"
},

Python:

"files.autoSave": "afterDelay",
"files.autoSaveDelay": 500,

"[python]": {
    "editor.defaultFormatter": "ms-python.python",
    "editor.insertSpaces": true
},

"python.pythonPath": "venv\\Scripts\\python.exe",
"python.analysis.completeFunctionParens": true,
"python.linting.flake8Enabled": true,
"python.linting.pycodestyleEnabled": true,
"python.linting.pycodestylePath": "[MyPathHere]",
"python.linting.flake8Path": "[MyPathHere]",
"python.formatting.provider": "black"

如何解决这种奇怪的行为?

谢谢

python visual-studio-code vscode-code-runner
2个回答
5
投票

这是代码运行程序清除以前的输出的问题,将其设置为 false 并手动将清除命令添加到其执行器映射中,最终结果应该如下所示。所有这些都将在项目的 settings.json 文件中完成,位于 .vscode 文件夹下。

{
    "code-runner.runInTerminal": true,
    "code-runner.clearPreviousOutput": false,
    "code-runner.executorMap": {
        "c": "clear; cd $dir && gcc $fileName -o $fileNameWithoutExt && 
                   $dir$fileNameWithoutExt",
        "cpp": "clear; cd $dir && g++ $fileName -o $fileNameWithoutExt && 
                   $dir$fileNameWithoutExt",
    }
}

0
投票

enter image description here

兄弟,我也遇到了同样的问题,但我没有使用代码运行器,而且,我是编码新手,所以我不知道如何处理您收到的回复代码。你能帮我一点忙吗?

© www.soinside.com 2019 - 2024. All rights reserved.