[tool] Visual Studio Code python配置


語言設置

安裝中文插件即可成為中文

 

選擇一個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
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM