我正在尝试在VS代码中调试以下脚本:
import os
import argparse
def parseArgs():
parser = argparse.ArgumentParser()
parser.add_argument("-cn", "--cert_names", nargs="+", default=None, help='Provide one or several cert names to be created')
parser.add_argument('-pw', '--password', action='store_true', help='Provide a password for private keys and certs')
args = parser.parse_args()
if not args.cert_names:
print("Please provide one or more cert names")
def main():
parseArgs()
print(args.cert_names)
这是我正在使用的launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File and libraries",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode" : false,
"args": ["-cn cert1 cert2 cert3 cert4"],
"cwd": "${fileDirname}",
}
]
}
在VS代码中运行调试器后,我收到以下消息: create_certs.py:错误:无法识别的参数:-cn cert1 cert2 cert3 cert4
我想要的是将该列表作为参数传递给脚本, 我也尝试过使用“args”:[“--cert_names cert1 cert2 cert3 cert4”],结果相同
有人知道我哪里出错了吗
尝试分别放置arg,如:
否则,它们都会作为一个大论点通过
相关问题 更多 >
编程相关推荐