python argparse:我的帮助,不是自动生成的,而是单个选项的简短帮助

时间:2017-04-21 14:12:31

标签: python argparse

argparse中有没有办法 打印 我的帮助,不是自动生成的--help
但单一选项只有短help=? 一个例子:

    # my help, not auto-generated --
if len(sys.argv) >= 1  and sys.argv[1].startswith(( "-h", "--h" )):
    print __doc__
    sys.exit()

p = argparse.ArgumentParser( usage="" )

    # want to print only this short help= for e.g. `-help -col`
p.add_argument( "-col", default=1, type=int,
                        help="the column to look at and color, 1 2 3 ..." )

    # and only this help= for e.g. `-help -color`
p.add_argument( "-color", "-colour", default="red",
                        help="one of: r g b red green blue " )

0 个答案:

没有答案