gpt4 book ai didi

python - 使用 Python argparse 创建隐藏参数

转载 作者:IT老高 更新时间:2023-10-28 21:08:05 35 4
gpt4 key购买 nike

是否可以在 python 中添加参数 argparse.ArgumentParser没有它出现在用法或帮助中(script.py --help)?

最佳答案

是的,您可以将 help 选项设置为 add_argumentargparse.SUPPRESS。这是 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 - 使用 Python argparse 创建隐藏参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11114589/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com