运行以下代码会导致此错误:
TypeError:init()得到了一个意外的关键字参数“帮助”
代码:
import click
@click.command()
@click.argument('command', required=1, help="start|stop|restart")
@click.option('--debug/--no-debug', default=False, help="Run in foreground")
def main(command, debug):
print (command)
print (debug)
if __name__ == '__main__':
main()
完整的错误输出:
$ python3 foo.py start
Traceback (most recent call last):
File "foo.py", line 5, in <module>
@click.option('--debug/--no-debug', default=False, help="Run in foreground")
File "/home/cbetti/python/lib/python3/dist-packages/click-4.0-py3.4.egg/click/decorators.py", line 148, in decorator
_param_memo(f, ArgumentClass(param_decls, **attrs))
File "/home/cbetti/python/lib/python3/dist-packages/click-4.0-py3.4.egg/click/core.py", line 1618, in __init__
Parameter.__init__(self, param_decls, required=required, **attrs)
TypeError: __init__() got an unexpected keyword argument 'help'
为什么会出现这个错误?