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

如何让Python代码的输出显示在VS Code终端中

让VS Code中Python代码输出显示在终端的设置方法

有几种简单的设置方式可以解决这个问题:

方法一:通过可视化设置界面修改

  1. 打开VS Code的设置界面(快捷键 Ctrl+, / Cmd+,)
  2. 在搜索框输入 python run execution mode
  3. 找到「Python > Run: Execution Mode」选项,将默认的「Output」改为「Terminal」

方法二:直接修改settings.json配置

  1. 打开命令面板(快捷键 Ctrl+Shift+P / Cmd+Shift+P)
  2. 输入并选择「Open Settings (JSON)」
  3. 在配置文件中添加或修改以下内容:
    "python.runExecutionMode": "terminal"
    
    保存文件后,后续运行Python代码就会默认在终端输出。

方法三:调试模式下指定终端输出

如果是通过调试功能运行代码,需要修改launch.json配置:

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

内容的提问来源于stack exchange,提问作者Flying_Griffen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 00:21:40