python - 单击命令不再是功能
问题描述
应用@click.command()
装饰器后,被装饰的函数变为 aCommand
并且不能再作为普通函数调用。但是,它仍然是可调用的,如果我将参数作为字符串列表传递,它似乎可以工作。
import click
@click.command()
@click.argument('info', nargs=-1)
def hello(info):
print(info)
hello(['asdf'])
这有效,返回(u'asdf')
。但是,当我这样做时:
hello([1234])
它失败了TypeError: object of type 'int' has no len()
。那么我应该将 aCommand
视为它自己的东西,并且永远不要尝试通过导入来调用它吗?
解决方案
推荐阅读
- java - 如何在调用其 write() 方法之前获取 SXSSFWorkbook 的大小?
- mysql - 使用 hibernate、SpringBoot、MySql 和 JSP 的 Spring-boot 应用程序
- c++ - 使用 C++ 读取具有两个连续分隔符的 csv 文件
- cors - Ionic v4 withCredentials true 给我 cors 错误
- java - 在Java中使用父类名存储时如何返回继承的对象
- mysql - 从表中检索信息 SELECET
- mysql - 从选择/联合构建表
- go - 如何创建一个包罗万象的 Go 环境以满足提出的要求:“应用程序必须在共享服务器上编译”
- javascript - 在没有参考的情况下停止背景音频
- c - 使用 Print (gnu-efi) 设置打印文本的颜色