python Python装饰器演示

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python装饰器演示相关的知识,希望对你有一定的参考价值。

def log3(func):
    '''embedded functions inside log'''
    def internal(name):
        return "Result is:" + func(name)
    return internal
hello = log3(hello)
print(hello("3-----me again"))

@log3
def hello5(name):
    return f"hello: {name}"

print(hello5("5-----me again again"))

以上是关于python Python装饰器演示的主要内容,如果未能解决你的问题,请参考以下文章

python-装饰器简述

Python装饰器实现日志记录

python,不用装饰器实现登陆器小程序

对python中的参数进行操作的嵌套函数装饰器

Python装饰器

python高阶3 python装饰器