在VS Code中运行Python脚本时如何隐藏文件路径?

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

每次运行代码时,底部的终端都会显示此长名称(我认为是文件位置)以及应该显示的任何输出。

有没有办法使它消失?

这是它的外观:

(screenshot of what's going on)

administrator@Machintosh-2 Exercise Files Python % /user/bin/python3...
Hello world!  
administrator@Machintosh-2 Exercise Files Python %
python visual-studio-code vscode-settings
1个回答
0
投票

AFAIK,无法隐藏路径,因为VS Code集成终端基本上是在使用OS /系统的基础终端。在终端上运行Python脚本通常需要:

<path/to/python/interpreter> <path/to/python/file>

如果您想要“更清洁”的控制台输出,则可以创建debug/launch configuration for Python,然后将console配置设置为console

。vscode / launch.json

internalConsole

这将在Debug Console选项卡而不是Terminal选项卡中显示输出。无论您将脚本打印到控制台什么,都将没有更多路径。

样本输出

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "run-my-script", "type": "python", "request": "launch", "program": "${workspaceFolder}/path/to/your_script.py", "console": "internalConsole" }, ... ] }

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