您可以tasks.json
通过将一组任务对象分配给任务属性来定义多个任务,如下所示:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
}
此外,Ctrl++Shift运行B默认的构建任务,因此您可能需要设置"workbench.action.tasks.runTask"
键绑定。
{
"key": "ctrl+shift+b",
"command": "workbench.action.tasks.runTask"
}
完成后,您可以在使用workbench.action.tasks.runTask
命令时选择任务,如下所示:

您还可以通过设置任务的"group"
属性来选择您的默认构建任务。在这里,在以下代码段中,您的"python3"
任务将作为默认构建任务运行。
...
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
...
您可以在此处阅读有关任务的更多信息:VSCode 中的任务