我们在python脚本中经常看到 action = "store_true,如下图:
parser.add_argument( '--image', default=False, action="store_true", help='Image detection mode, will ignore all positional arguments' )
如果运行代码时加了 --image ,那么 image为true
如果没加 --image,那么image为False
这种写法通常用于判断,如下:
if FLAGS.image: # 用于判断 """ Image detection mode, disregard any remaining command line arguments """ print("Image detection mode") if "input" in FLAGS: print(" Ignoring remaining command line arguments: " + FLAGS.input + "," + FLAGS.output) detect_img(YOLO(**vars(FLAGS))) elif "input" in FLAGS: detect_video(YOLO(**vars(FLAGS)), FLAGS.input, FLAGS.output) else: print("Must specify at least video_input_path. See usage with --help.")
标签:python,image,parse,--,FLAGS,action,input,true,store From: https://www.cnblogs.com/chentiao/p/17486082.html