sla*_*pha 4 python macos visual-studio-code
我使用的是 Mac OS X 的 VS Code。有没有办法让 VS Code 在每次运行 Python 程序时自动清除显示 Python 程序输出的终端窗口?我想在执行之前清除终端窗口。
编辑:查看建议的链接,我想使用 VS Code 任务来执行此操作。我发现我需要编辑 .vscode 目录中的tasks.json 文件,但是每次运行Python 文件之前如何触发该任务,以及我将为该任务填写哪些其他参数?
这里还是有点困惑。"command"我要为和投入什么"label"?
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello",
"clear": "true"
}
]
}
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以简单地导入 os 并使用命令清除终端。
对于 Windows:
import os
os.system("cls")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8072 次 |
| 最近记录: |