分享:VS Code Python task.json

作者: gomibako | 来源:发表于2017-10-06 17:34 被阅读707次

笔者的Python代码文件存放在带有空格的目录中,按下ctrl+shift+b build的时候Terminal显示出错

[Errno 2] No such file or directory

快速排查原因是Path中含有space所致(eg. C:\Users\Winnie the Pooh)

解决方法:在${file}外围加上单引号 '

另分享一个新版的python task.json配置如下

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "Run Python Code",
            "type": "shell",
            "command": "python",
            "args": [
                "'${file}'"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "shared"
            }
        }
    ]
}

笔者的Python测试代码如下:

ba = bytearray([65, 66, 84, 95])
print(ba) # bytearray(b'ABT_')

相关文章

网友评论

本文标题:分享:VS Code Python task.json

本文链接:https://www.haomeiwen.com/subject/dkdryxtx.html