python:arg_解析器参数添加别名

python:arg_解析器参数添加别名,python,alias,argparse,Python,Alias,Argparse,我试图使用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,

我试图使用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")

这可以通过添加
metavar

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

工作完美!工作完美!