【发布时间】:2023-02-07 02:06:07
【问题描述】:
我正在尝试在 python 中使用 Typer 包。
我写了这段代码:
import typer
app = typer.Typer()
@app.command()
def hello(name: str):
print(f"Hello {name}")
我正在尝试使用以下命令运行它:
python main.py hello Patryk
我的终端没有显示任何东西。没有错误,没有文本。
Python 版本:Python 3.9.13 (pipenv) 系统:Macos Ventura 13.1 终端:iTerm2 Build 3.4.18 和 Macos 默认终端
我试图不使用 pipenv 并在我的机器上安装所有打字机。
我也试过这段代码:
import typer
def main(name: str):
print(f"Hello {name}")
if __name__ == "__main__":
typer.run(main)
当我用这个命令运行它时它起作用了:
python main.py
【问题讨论】:
标签: python command-line-interface pipenv typer