首页 > 编程语言 > 详细

python装饰器(3)

时间:2017-09-02 19:45:42      阅读:255      评论:0      收藏:0      [点我收藏+]

另一种实现方式:

 1 __author__ = "csy"
 2 
 3 def test2(func):
 4     def test1():
 5         func()
 6         print(func)
 7     return test1
 8 
 9 def bar2():
10     print(in the bar2)
11 
12 bar2 = test2(bar2)    # test2将bar2作为变量在嵌套函数test1中调用,再将test1的内存地址作为返回值重新赋给bar2
13 bar2()

 

python装饰器(3)

原文:http://www.cnblogs.com/csy113/p/7467358.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!