python fire 命令行参数

code

import firedef t(name, age=20): print(f"{name} : {age}")if __name__ == "__main__": fire.Fire(t)

usage

python test.py --name=abcabc : 20python test.py --name=user --age=10 user : 10python test.py --helpNAME test.pySYNOPSIS test.py NAME AGEPOSITIONAL ARGUMENTS NAME AGENOTES You can also use flags syntax for POSITIONAL ARGUMENTS