python---装饰器

python装饰器就是用于拓展原来函数功能的一种函数,这个函数的特殊之处在于它的返回值也是一个函数,使用python装饰器的好处就是在不用更改原函数的代码前提下给函数增加新的功能。 

例如,源函数代码如下: 

import time
def func():
    print("hello")
    time.sleep(1)
    print("world")

猜你喜欢

转载自www.cnblogs.com/saryli/p/9031455.html