.vscode目录结构:
在这里插入图片描述
配置文件内容
.env的内容如下:

PYTHONPATH=./:${PYTHONPATH}

其中./表示当前工作目录
settings.json的内容如下:
配置一

{
    "python.pythonPath": "/home/jovyan/.conda/envs/tf_1.15/bin/python",
    "jupyter.jupyterServerType": "local",
    "python.linting.enabled": false,
    "terminal.integrated.fontFamily": "monospace",
    "terminal.integrated.fontSize": 16,
    "python.envFile": "${workspaceFolder}/.vscode/.env", #引用环境变量文件`.env`
}

配置二

{
    "terminal.integrated.fontFamily": "monospace",
    "terminal.integrated.fontSize": 16,
    "python.envFile": "${workspaceFolder}/.vscode/.env",
    "git.ignoreLimitWarning": true,
    "editor.formatOnSave": true,
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true
    },
}

launch.json的内容如下:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false     #`debug源码`
        }
    ]
}

更多推荐