1. 程式人生 > >使用Vscode寫python

使用Vscode寫python

idle nbsp spl iter .json 路徑 sele splay variable

在python官網下載好python2.x 或者 3.x, 然後在vscode 下載python插件.

寫一個python程序, 運行, vscode會自動提示你配置python執行路徑,並幫你創建好.vscode文件夾.

除了task需要配置外,其他的vscode都會自動幫你配好. 下面講一下怎麽配置task使得可以用contrl+shift+B就運行程序.

(也可以使用shift+enter來運行部分選中的代碼,但是沒有整體性. 運行爬蟲代碼時總是有莫名其妙的錯誤,但是在IDLE裏面卻沒錯)

寫好python程序, 按ctrl + shift + B, 在提示界面選擇最下面的other. 在自動創建的task文件裏面進行配置,配置文件如下:

{
    // 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": "C:/Python/Python37/python.exe",
            "args": [
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
        }
    ]
}
技術分享圖片

使用Vscode寫python