美文网首页python交流学习
Python中的Director插件,你需要了解一下

Python中的Director插件,你需要了解一下

作者: 78c40b03ee4e | 来源:发表于2019-03-12 21:19 被阅读0次

    前言

    Director 是一个Python的类库用来开发命令行工具的插件,利用它可以很方便的添加新的功能。

    下面是一个简单的例子:

    #!/usr/bin/env python
    
    import exceptions
    import sys
    
    from director import ActionRunner
    from director.filter import ExceptionFilter
    from director.filter import Filter
    
    if __name__ == '__main__':
        # Create and use exception filters
        # Note you don't have to use filters. If you don't pass filter in
        # to ActionRunner.run filters won't be used.
        filter = Filter()
        filter.register_filter(ExceptionFilter(exceptions.IOError, "TEST %s"))
        filter.register_filter(ExceptionFilter(exceptions.TypeError, "NO! %s"))
    
        # 'actions.package' is the package that holds the allowed plugin actions
        ar = ActionRunner(sys.argv, 'actions.package')
        ar.run(filter)·
    

    小编推荐一个学python的学习qun 740,3222,34
    无论你是大牛还是小白,是想转行还是想入行都可以来了解一起进步一起学习!裙内有开发工具,很多干货和技术资料分享!

    相关文章

      网友评论

        本文标题:Python中的Director插件,你需要了解一下

        本文链接:https://www.haomeiwen.com/subject/bnyopqtx.html