問(wèn)題
為了帶入?yún)?shù)調(diào)試python 程序,按照網(wǎng)上搜到的教程配置了lauch.json文件,文件中添加了"args": [“model” “0” “path”]
{
// 使用 IntelliSense 了解相關(guān)屬性。
// 懸停以查看現(xiàn)有屬性的描述。
// 欲了解更多信息,請(qǐng)?jiān)L問(wèn): 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": true,
"args":[ "****", "0", "*****" ]
}
]
}
但是點(diǎn)擊debug按鈕,并沒(méi)有讀取到launch文件中的args參數(shù),python中打印len(sys.argv)依然等于1。
原因
參考:vscode-python 中的 issues
vscode-doc: Python debugging in VS Code
簡(jiǎn)單來(lái)說(shuō)就是:
1、界面右上角的debug按鈕是一個(gè)擴(kuò)展插件,是獨(dú)立的debug系統(tǒng),不讀launch.json文件。所以在launch.json中的任何配置都不生效
2、F5/Run>Start Debugging,這兩個(gè)選項(xiàng)都可以很好地與launch.json設(shè)置配合使用。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-703301.html
解決方案
1、按F5(或菜單欄Run->Start Debugging)
2、在launch.json里添加"purpose": [“debug-in-terminal”], 使用purpose注意事項(xiàng)
3、點(diǎn)擊左側(cè)debug窗口里面的debug按鈕,它與debug系統(tǒng)是集成的。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-703301.html
到了這里,關(guān)于vscode debug python launch.json添加args不起作用的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!