首页 > 编程语言 > 详细

python 命令行工具 fire

时间:2018-02-26 18:38:31      阅读:214      评论:0      收藏:0      [点我收藏+]

简介

A library for automatically generating command line interfaces.

Python Fire is a library for automatically generating command line interfaces (CLIs) with a single line of code.

It will turn any Python module, class, object, function, etc. (any Python component will work!) into a CLI. It’s called Fire because when you call Fire(), it fires off your command.

安装

pip install fire

使用

例子

import fire

class Calculator(object):
    """A simple calculator class."""

    def double(self, number):
        print ‘2 *‘,number,‘=‘,2 * number

    def doublekill(self, number, n):
        print ‘n:‘,n
        print ‘2 *‘,number,‘=‘,2 * number

if __name__ == ‘__main__‘:
    fire.Fire(Calculator)

执行结果技术分享图片

python 命令行工具 fire

原文:https://www.cnblogs.com/xiaomingtx/p/8474544.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!