【发布时间】:2021-09-14 23:47:24
【问题描述】:
我正在尝试使用 VSCode 调试器调试我的 python 模块。我准备我的launch.json 文件如下:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Python: Current file",
"url": "http://localhost:8081",
"webRoot": "${workspaceFolder}",
"runtimeArgs": ["arg1", "arg2", '{"host":"https://x.xxx.xx.xxx/console","port":443,"selfSignedCert": false}', '{"auth": {"sec": "ccccccc-dddd-eeee-ffff-gggggggggg"}}', "args3"]
}
]
}
但我认为这不是传递对象'{"host":"https://x.xxx.xx.xxx/console","port":443,"selfSignedCert": false}' 和'{"auth": {"sec": "ccccccc-dddd-eeee-ffff-gggggggggg"}}' 的正确方法。
我想将对象按原样传递到模块中,即使用单引号。有人可以帮助我以正确的方式做到这一点吗?
【问题讨论】:
-
因为
launch.json必须在JSON format 文件中,所以不能在JSON 需要双引号的地方使用单引号,因此你不能做你想做的事。你为什么要他们呢?我想这可能是XY problem。 -
……续。如果您希望字符串嵌入双引号字符,您可以像这样转义这些字符:
"{\"host\":\"https://x.xxx.xx.xxx/console\",\"port\":443,\"selfSignedCert\": false}"和"{\"auth\": {\"sec\": \"ccccccc-dddd-eeee-ffff-gggggggggg\"}}" -
谢谢,这很清楚。但只是让您知道,这就是我的程序期望输入的方式。因此我必须这样通过。在接受输入后,我可以用另一种方法来处理它们。非常感谢@martineau
-
尴尬只是设置被存储在 JSON 格式文件中这一事实的产物。
标签: python debugging visual-studio-code vscode-debugger