为什么我在运行程序时 会报这样一个错误

usage: scan.py [-h] (--images IMAGES | --image IMAGE) [-i]
scan.py: error: one of the arguments --images --image is required

是这里出了问题吗?

 ap = argparse.ArgumentParser()
    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("--images", help="Directory of images to be scanned")
    group.add_argument("--image", help="Path to single image to be scanned")
    ap.add_argument("-i", action='store_true',
        help = "Flag for manually verifying and/or setting document corners")

    args = vars(ap.parse_args())
    im_dir = args["images"]
    im_file_path = args["image"]
    interactive_mode = args["i"]

    scanner = DocScanner(interactive_mode)

    valid_formats = [".jpg", ".jpeg", ".jp2", ".png", ".bmp", ".tiff", ".tif"]

    get_ext = lambda f: os.path.splitext(f)[1].lower()
    if im_file_path:
        scanner.scan(im_file_path)

    # Scan all valid images in directory specified by command line argument --images <IMAGE_DIR>
    else:
        im_files = [f for f in os.listdir(im_dir) if get_ext(f) in valid_formats]
        for im in im_files:
            scanner.scan(im_dir + '/' + im)

有必传参数哈,需要在cmd窗口指定参数进行运行或者修改 3~5行的参数为非必须,并给定默认值 required=False, default="images/01B.png" 运行

python args命令行参数可参考:
Python必备基本技能——命令行参数args详解_程序媛一枚~的博客-CSDN博客 这篇博客将介绍一项开发人员、工程师和计算机科学家必备的技能——命令行参数(原理及使用)。 依赖argparse库,可以pip安装。vars会将命令行参数解析成字典,argparse Python 库在解析过程中用下划线替换破折号(若命令行参数中有中划线 “-” 需要用下划线 “_” 解析。) https://blog.csdn.net/qq_40985985/article/details/118304605