命令行参数在python中不起作用

2024-06-26 14:54:25 发布

您现在位置:Python中文网/ 问答频道 /正文

--A_Z_Handwrite Data.csv:Kaggle A-Z数据集的路径(第3行和第4行) --手写识别:输出经过训练的手写识别模型的路径(第5行和第6行)


# construct the argument parser and parse the arguments
    ap = argparse.ArgumentParser()
    ap.add_argument("-a", "--A_Z_Handwritten Data.csv", required=True,
        help="path to A-Z dataset")
    ap.add_argument("-m", "--HandWritingRecognition", type=str, required=True,
        help="path to output trained handwriting recognition mode")
    # ap.add_argument("-p", "--plot", type=str, default="plot.png",
    #   help="/home/gaurav/Desktop/HandWritingRecognition/")
    args = vars(ap.parse_args())

这就是错误

usage: ipykernel_launcher.py [-h] -a A_Z_HANDWRITTEN DATA.CSV -m
                             HANDWRITINGRECOGNITION
ipykernel_launcher.py: error: the following arguments are required: -a/--A_Z_Handwritten Data.csv, -m/--HandWritingRecognition
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

Tags: csvtheto路径adddataparserequired