python : arg_parser 参数添加别名

python : arg_parser argument add alias

我正在尝试使用 python 参数解析进行一些特定的打印,但有些事情我无法做到。

parser.add_argument('-m' , help="test a specific module")

以上是我的代码。

optional arguments:
  -h, --help   show this help message and exit
  -m M         test a specific module

以上是结果。

但我想要的是:

optional arguments:
  -h, --help   show this help message and exit
  -m MODULE    test a specific module

我知道这不是很重要,但我真的很想得到这个输出。

谢谢!

这可以通过添加 metavar

来解决
parser.add_argument('-m', metavar='MODULE', help="test a specific module")