每次我运行代码时,底部的终端都会显示这个长名称(我认为是文件位置)以及应该显示的任何输出。
有没有办法使它消失?
看起来是这样的:
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>
如果您想要“更干净”的控制台输出,则可以为Python创建调试/启动配置,然后将console
配置设置为internalConsole
:
.vscode / launch.json
{
// 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"
},
...
]
}
这将在“ 调试控制台”选项卡而不是“ 终端”选项卡中显示输出。
无论您将脚本打印到控制台什么,都将没有更多路径。
样本输出:
您是正确的,没有直接支持来隐藏文件路径。