語言設置
安裝中文插件即可成為中文
選擇一個Python解釋器
Python是一種解釋型語言,為了運行Python代碼並獲取Python IntelliSense,您必須告訴VS Code使用哪個解釋器。
在VS Code中,通過打開命令選項板(Ctrl + Shift + P)選擇Python 3解釋器
輸入 Python: Select Interpreter
選擇你的解釋器
創建一個Python Hello World源代碼文件
從文件資源管理器工具欄中,單擊文件hello
夾上的“新建文件”按鈕:
命名該文件hello.py
,它將自動在編輯器中打開:
運行Hello World
hello.p y
使用Python 運行很簡單。在編輯器中單擊鼠標右鍵,然后選擇“在終端中運行Python文件”(自動保存文件):
該命令打開一個終端面板,在其中自動激活Python解釋器,然后運行python3 hello.py
(macOS / Linux)或python hello.py
(Windows):
在VS Code中可以運行Python的另外兩種方法:
- 選擇一行或多行,然后按Shift + Enter或右鍵單擊並選擇在Python終端中運行選擇/行。此命令非常便於測試文件的一部分。
- 使用Python:Start REPL命令打開當前所選Python解釋器的REPL終端。然后,在REPL中,您可以一次輸入和運行一行代碼。
上述所有使用教程都可以在以下官方tutorial找到
https://code.visualstudio.com/docs/languages/python
自用插件列表
python preview可以充當spyder用 右鍵py文件標簽 選擇預覽該文件
能夠看到具體的數據結構
settings.json 配置 (裝了One Dark Pro)
{ "python.pythonPath": "D:\\python\\python.exe", "workbench.colorTheme": "One Dark Pro Bold", "editor.fontSize": 14, "editor.lineHeight": 20, "editor.tokenColorCustomizations": { "textMateRules": [ { "name": "Comments", "scope": "comment, punctuation.definition.comment", "settings": { "fontStyle": "" } }, { "name": "js/ts italic", "scope": "entity.other.attribute-name.js,entity.other.attribute-name.ts,entity.other.attribute-name.jsx,entity.other.attribute-name.tsx,variable.parameter,variable.language.super", "settings": { "fontStyle": "" } }, { "name": "js ts this", "scope": "var.this,variable.language.this.js,variable.language.this.ts,variable.language.this.jsx,variable.language.this.tsx", "settings": { "fontStyle": "" } } ] }, "explorer.confirmDelete": false }