Article / 文章中心

Python编程:fire库自动生成命令行接口

发布时间:2021-11-23 点击数:445

命令行接口(Command Line Interface,简称CLI)

# -*- coding: utf-8 -*-  # @File    : fire_CLI_demo.py # @Date    : 2018-06-03  import fire  class Person(object):  def hello(self, name="world"):  print("hell %s"% name)  if __name__ == '__main__':  fire.Fire(Person)  # 运行命令: python fire_CLI_demo.py hello