You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何清除VS Code终端中Python运行时的路径等冗余内容

清除VS Code运行Python时终端的冗余内容

方法一:改用调试控制台输出

  1. 打开VS Code的「运行和调试」面板(快捷键:Ctrl+Shift+D)
  2. 点击「创建launch.json文件」,选择Python环境
  3. 在生成的launch.json配置中,将console字段设置为internalConsole,示例配置如下:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "internalConsole"
        }
    ]
}

配置完成后,运行代码时结果会输出到「调试控制台」,仅显示程序运行内容,无终端冗余信息。

方法二:修改PowerShell启动参数

  1. 打开VS Code设置(快捷键:Ctrl+,)
  2. 搜索terminal.integrated.profiles.windows,找到PowerShell的配置项
  3. 修改其args为["-NoLogo", "-Command", "& '${command:python.interpreterPath}' '${file}'"],同时设置默认终端为PowerShell,示例配置:
"terminal.integrated.profiles.windows": {
    "PowerShell": {
        "source": "PowerShell",
        "args": ["-NoLogo", "-Command", "& '${command:python.interpreterPath}' '${file}'"]
    }
},
"terminal.integrated.defaultProfile.windows": "PowerShell"

-NoLogo参数会移除PowerShell启动时的版权提示,直接执行Python命令,减少路径等冗余输出。

方法三:使用Code Runner插件

  1. 在VS Code扩展市场安装「Code Runner」插件
  2. 打开插件设置,找到「Code Runner: Run In Terminal」选项并取消勾选
  3. 运行代码时,结果会输出到「输出」面板,仅保留程序运行结果。

内容的提问来源于stack exchange,提问作者Dimuth De Zoysa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 10:02:11