1.創(chuàng)建launch.json文件
通過調(diào)試配置項(xiàng)配置的
2.編輯launch.json
在configuration中使用參數(shù)"cwd": "${fileDirname}",這樣在debug時(shí)可以切換到當(dāng)前文件所在的目錄钓试,使用相對路徑装黑。
{
// 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",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "D:\\Users\\mas\\AppData\\Local\\Programs\\Python\\Python37\\python.exe",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
}