vscode 设置当前路径为 运行路径

1.【运行】- 【打开配置】

{

    // 使用 IntelliSense 了解相关属性。

    // 悬停以查看现有属性的描述。

    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387

    "version": "0.2.0",

    "configurations": [

        {

            "name": "Python: 当前文件",

            "type": "python",

            "request": "launch",

            "program": "${file}",

            "console": "integratedTerminal",

            "cwd": "${fileDirname}"

        }

    ]

}

2.python 代码 

import sys

sys.path.append(".")

猜你喜欢

转载自blog.csdn.net/qq_43309882/article/details/120889411