argparse帮助,无需重复的ALLCAPS
发布于 2021-01-29 16:01:36
我想为我的选项显示argparse帮助以同样的方式默认-h
,--help
并且-v
,--version
是,没有选项后ALLCAPS文本,或至少不重复的CAPS。
import argparse
p = argparse.ArgumentParser("a foo bar dustup")
p.add_argument('-i', '--ini', help="use alternate ini file")
print '\n', p.parse_args()
这是我目前得到的python foobar.py -h
:
usage: a foo bar dustup [-h] [-i INI]
optional arguments:
-h, --help show this help message and exit
-i INI, --ini INI use alternate ini
这就是我想要的:
usage: a foo bar dustup [-h] [-i INI]
optional arguments:
-h, --help show this help message and exit
-i, --ini INI use alternate ini
这也是可以接受的:
-i, --ini use alternate ini
我正在使用python 2.7。
关注者
0
被浏览
45
1 个回答