1、安装
pip install fire
2、使用
import fire
def add(a,b):
c=a+b
return c
def sub(a,b):
return a-b
if __name__=='__main__':
fire.Fire()
命令行如下:
python test.py sub --a 1 --b 3 或者 python test.py sub 1 3
python test.py add --a 1 --b 3 或者 python test.py add 1 3