使用 Python argparse 创建隐藏参数 [英] Creating hidden arguments with Python argparse
本文介绍了使用 Python argparse 创建隐藏参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将参数添加到 python argparse.ArgumentParser
没有出现在用法或帮助中 (script.py --help
)?
解决方案
是的,您可以将 help
选项设置为 add_argument
为 argparse.SUPPRESS代码>.下面是 argparse 文档 中的一个示例:
Is it possible to add an Argument to an python argparse.ArgumentParser
without it showing up in the usage or help (script.py --help
)?
解决方案
Yes, you can set the help
option to add_argument
to argparse.SUPPRESS
. Here's an example from the argparse documentation:
>>> 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
这篇关于使用 Python argparse 创建隐藏参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文