这是我的代码
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("required_arg", metavar="username:pass@hostname")
parser.add_argument("--optional_arg",
help="This optional argument should have args and
kwargs implemented in it as I want to make
it flexible eg.
it may have optional_arg1,
optional_arg2, key1=value1, key2=value2 or
it may have optional_arg1, key1=value1,
key2=value2, key3=value3")
有人能告诉我在这个add_argument()部分实现* args和** kwargs的方法吗?
答案 0 :(得分:0)
我想你可能想看看这样的事情:
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subparser')