python 装饰器

'''
概念:是一个闭包,把一个函数当做参数,返回一个替代版的函数,本质上就是一个返回函数的函数

'''

#简单的装饰器
def func1():
print("sunck is a good man")

def outer(func):
def inner():
print("*******************")
func()
return inner
#f是函数func1的加强版本
f = outer(func1)
f()
posted @ 2020-02-02 18:40  i勤能补拙  阅读(162)  评论(0编辑  收藏  举报