1. 程式人生 > >VSCode配置python調試環境

VSCode配置python調試環境

選擇 shift 使用 a20 ctrl false div style vsc

VSCode配置python調試環境

一、安裝好Python環境

二、下載VSCode

下載地址:https://code.visualstudio.com/download

三 、安裝VSCode

安裝完後是英文版本,需要安裝中文(簡體)語言包插件,如下圖。然後重新啟動VSCode就是中文版本了。

另外建議安裝如下幾個插件,在編程中可以提示代碼。

技術分享圖片

四、設置編輯區與終端體

技術分享圖片

技術分享圖片

技術分享圖片

復制如下代碼到用戶設置中,設置編輯區字體及終端字體大小,及Python的默認路徑

技術分享圖片
1     "editor.fontSize": 20,
2     "terminal.integrated.fontSize": 18,
3 "python.pythonPath":"C:\\Python36-32\\python.exe", 4 "python.linting.enabled": false,
View Code

如下圖:

技術分享圖片

五、配置運行Python環境

打開一個文件夾,當成一個工作區,然後再打開一個Python文件,比如test.py,代碼如下:

技術分享圖片
1 import os
2 print (os.name)
3 print ("Hello World")
View Code

技術分享圖片

然後按Ctrl+Shift+B,出現如下圖,點擊 配置生產任務...

技術分享圖片

出現如下圖,點擊使用模板創建tasks.json文件

技術分享圖片

選擇Others 運行任意外部命令的示例

技術分享圖片

出現如下畫面

技術分享圖片

修改一下,把如下代碼復制到上面這個框框裏面

技術分享圖片
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Jacky",
            "type": "shell",
            "command": "C:\\Python36-32\\python
", "args": [ "${file}" ], "options": { "env": {"PYTHONIOENCODING":"UTF-8"} }, "group": { "kind": "build", "isDefault": true } } ] }
View Code

結果如下所示:

技術分享圖片

接下來就可以 按 Ctrl + Shift +B運行代碼了

技術分享圖片

VSCode配置python調試環境