摘要: def outer(func): def inner(age): if age < 0: age = 0 func(age) return inner#使用@符号将装饰器应用到函数#@python2.4支持使用@符号@outer #相当于say = outer(say)def say(age): p 阅读全文
posted @ 2020-02-02 21:36 i勤能补拙 阅读(192) 评论(0) 推荐(0)
摘要: '''概念:是一个闭包,把一个函数当做参数,返回一个替代版的函数,本质上就是一个返回函数的函数'''#简单的装饰器def func1(): print("sunck is a good man")def outer(func): def inner(): print("*************** 阅读全文
posted @ 2020-02-02 18:40 i勤能补拙 阅读(173) 评论(0) 推荐(0)