是否可以在python中添加一个Argument argparse.ArgumentParser而不显示在usage或help(script.py --help)中?
srg*_*erg 147
是的,您可以将help选项设置add_argument为argparse.SUPPRESS.这是argparse文档中的一个示例:
>>> parser = argparse.ArgumentParser(prog='frobble')
>>> parser.add_argument('--foo', help=argparse.SUPPRESS)
>>> parser.print_help()
usage: frobble [-h]
optional arguments:
-h, --help show this help message and exit
Run Code Online (Sandbox Code Playgroud)