如何解析 python (spyder) 中的参数?
How to parse arguments in python (spyder)?
我正在关注 this 教程并尝试 运行 脚本的以下部分。我正在使用 python 3.7 和 spyder 3.3.4。
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dataset", required=True,
help="path to input dataset (i.e., directory of images)")
ap.add_argument("-m", "--model", required=True,
help="path to output model")
ap.add_argument("-l", "--labelbin", required=True,
help="path to output label binarizer")
ap.add_argument("-p", "--plot", type=str, default="plot.png",
help="path to output accuracy/loss plot")
args = vars(ap.parse_args())
我已尝试转到 运行 > 每个文件的配置并按照 this post and and this post 的建议输入参数。
command line options: path1, path2, path3, path4
我为上面的参数填写了适当的路径,然后 运行 脚本,但是出现下面的错误。
usage: train.py [-h] -d DATASET -m MODEL -l LABELBIN [-p PLOT]
train.py: error: the following arguments are required: -d/--dataset,
-m/--model, -l/--labelbin An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
我怎样才能适当地修复 运行 我的脚本的这个错误并在 spyder 中传递参数?
您可以通过在设置中执行特殊操作 运行 并按照参数的预期顺序来解析参数。
我正在关注 this 教程并尝试 运行 脚本的以下部分。我正在使用 python 3.7 和 spyder 3.3.4。
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dataset", required=True,
help="path to input dataset (i.e., directory of images)")
ap.add_argument("-m", "--model", required=True,
help="path to output model")
ap.add_argument("-l", "--labelbin", required=True,
help="path to output label binarizer")
ap.add_argument("-p", "--plot", type=str, default="plot.png",
help="path to output accuracy/loss plot")
args = vars(ap.parse_args())
我已尝试转到 运行 > 每个文件的配置并按照 this post and and this post 的建议输入参数。
command line options: path1, path2, path3, path4
我为上面的参数填写了适当的路径,然后 运行 脚本,但是出现下面的错误。
usage: train.py [-h] -d DATASET -m MODEL -l LABELBIN [-p PLOT] train.py: error: the following arguments are required: -d/--dataset, -m/--model, -l/--labelbin An exception has occurred, use %tb to see the full traceback. SystemExit: 2
我怎样才能适当地修复 运行 我的脚本的这个错误并在 spyder 中传递参数?
您可以通过在设置中执行特殊操作 运行 并按照参数的预期顺序来解析参数。