【问题标题】:Simplify Python Output in Visual Studio Code在 Visual Studio Code 中简化 Python 输出
【发布时间】:2021-02-21 19:22:14
【问题描述】:

在 Visual Studio 代码中,我想运行简单的 Python 代码 (using the code runner extension),它会为我提供有关运行时和文件位置的信息。我不想要那个,我可以把它剪掉,只有输出吗?

【问题讨论】:

  • 您是否正在从 Visual Studio Code 的“运行”菜单执行您的 python?如果是这样,那么您看到的系统信息(很可能)来自 bash 或 powershell(取决于您使用的是哪一个)。该行为将独立于 Visual Studio Code。当您在 Visual Studio Code 之外调用这些终端中的任何一个时,您应该会看到相同的系统信息。
  • @jim 这不是 bash 或 powershell - 这是本机 vscode 输出
  • 将输出标签更改为终端标签。在终端中,运行 python -u "hello world.py"
  • @jim 澄清一下,这实际上不是原生/内置 VS Code 输出,而是来自 Code Runner 扩展。 Python does not look like that 的原生 VS Code 输出(没有 [Running] 和 [Done] 标签)。

标签: python visual-studio-code


【解决方案1】:

由于您使用“Code Runner”扩展,我们可以设置它:

  1. 我们可以在“settings.json”中添加如下设置:

"code-runner.showExecutionMessage": false,

  1. 或者在“设置”中找到“showExecutionMessage”选项,取消勾选:

运行:

【讨论】:

  • 如果 python 代码要求用户输入,上述内容是否仍然允许?
  • @Jarhead1775 - 这是“输出”终端,所以只支持结果的输出,输入终端需要在“终端”中。
猜你喜欢
  • 1970-01-01
  • 2022-10-13
  • 2018-09-06
  • 1970-01-01
  • 2020-12-10
  • 1970-01-01
  • 1970-01-01
  • 2021-11-11
  • 1970-01-01
相关资源
最近更新 更多