每次运行代码时,底部的终端都会显示此长名称(我认为是文件位置)以及应该显示的任何输出。
有没有办法使它消失?
这是它的外观:
administrator@Machintosh-2 Exercise Files Python % /user/bin/python3... Hello world! administrator@Machintosh-2 Exercise Files Python %
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"
},
...
]
}