我尝试使用以下词典在argparse中生成参数:
inititateCmdMap = {
'-l': {
'help': 'list of transactions for type',
'choices': ['all', 'utxq', 'mtxq']},
'-u': {
'help', 'url of rest server'},
'-k': {
'help': 'something helpful'},
'-x': {
'help': 'expression'}}
但我不知道如何通过它作为以下例外:
[parser.add_argument(v[0], v[1]) for v in inititateCmdMap.items()]
in add_argument
kwargs = self._get_optional_kwargs(*args, **kwargs)
File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1446, in _get_optional_kwargs
if not option_string[0] in self.prefix_chars:
KeyError: 0
这有可能吗?你知道吗
你一直在传递dict本身,而不是打开它的内容。你知道吗
试着这样做:
相关问题 更多 >
编程相关推荐