美文网首页
python@装饰器作用

python@装饰器作用

作者: 郭欢小哥 | 来源:发表于2019-10-29 17:38 被阅读0次

    @装饰器

    def a(fun):

        def c():

            print("新功能")

            fun()

            print("新功能")

        return fun

    @a

    def b():

        print("之前的方法")

    对b函数进行修改,补充,通过@a将a装饰方法与b方法进行连接

    相关文章

      网友评论

          本文标题:python@装饰器作用

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