当前位置: 代码迷 >> 综合 >> nargs, action=“store_true
  详细解决方案

nargs, action=“store_true

热度:13   发布时间:2024-01-28 22:43:00.0

 问题如下:

    parser.add_argument("--output", nargs='?', type=str, default="",help = "[Optional] Video output path")parser.add_argument('--image', default=False, action="store_true",help='Image detection mode, will ignore all positional arguments')

查询结果

nargs='*'    表示参数个数可以为0个或者n个(n等于1,2,3...)
nargs=' '+'   表示参数个数为一个或多个,不能是0个
nargs='?'   表示参数个数为0个或者一个store_true: 如果给了这个参数,将其值标记为True,没给就为False
store_false 相反

 

  相关解决方案