当前位置 : 主页 > 编程语言 > python >

Python 装饰器

来源:互联网 收集:自由互联 发布时间:2021-06-25
1 # !/usr/bin/env python3 2 # -*- coding: utf-8 -*- 3 4 5 def out_func(fun): 6 def test(args): 7 print ( " 验证 " ) 8 return fun(args) 9 return test 10 11 12 @out_func 13 def func1(args): 14 print ( " this is func1! " + args) 15 return "

 

 

 1 #!/usr/bin/env python3
 2 # -*- coding: utf-8 -*-
 3 
 4 
 5 def out_func(fun):
 6     def test(args):
 7         print("验证")
 8         return fun(args)
 9     return test
10 
11 
12 @out_func
13 def func1(args):
14     print("this is func1! " + args)
15     return "return", func1
16 
17 
18 print(func1("bingfeng"))
网友评论