python中parse的action = store_true含义
我们在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.")
本文来自博客园,作者:海_纳百川,转载请注明原文链接:https://www.cnblogs.com/chentiao/p/17486082.html,如有侵权联系删除

浙公网安备 33010602011771号