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"]
argparse包处理命令行参数
get_ext = lambda f: os.path.splitext(f)[1].lower()
lambda表达式,作用:快速编写函数,def的简化版。
lambda表达式