![](/img/trans.png)
[英]Configure task using python in visual studio code for windows 10
[英]Create simple Task for Python in Visual Studio Code
我已经看到这个问题: How to execute Python code from within Visual Studio Code
但所有这些答案都是关于旧版本(“0.1.0”或“0.2.0”)的任务。 VS Code 现在是“2.0.0”版本,一些参数发生了变化。
我正在尝试通过Run Task
创建此任务:
任务.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run File",
"command": "python ${file}",
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
但它不起作用:错误信息:
ID为8的终端不存在(已经处理掉了吗?)
这里有什么问题?
我可以在终端中使用Run Python File in Terminal
中输入python myFile.py
- 它们都有效!
这是我的 tasks.json 文件,用于 python。
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Python",
"type": "shell",
"command": "python",
"args": [
"${file}"
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
如果您不知道,可以将其复制并粘贴到tasks.json
文件夹中的.vscode
文件中。 如果没有,您可以手动创建它。 现在您可以使用快捷键Ctrl+Shift+B
自动运行您的 python 代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.