1、修改terminal执行的路径在当前文件夹路径
搜索 python.terminal.executeInFileDir
勾选即可。
2、vscode中调试debug的路径设置
运行——添加配置——python:debuger解释器;
修改launch.json配置参数:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python 调试程序: 当前文件",
"type": "debugpy",
"request": "launch",
// "cwd": "${workspaceFolder}", //大多数默认的当前路径是根目录
"cwd": "${fileDirname}", //改成现在文件所在目录即可
"program": "${file}",
"console": "integratedTerminal"
}
]
}