#!/usr/local/bin/python3
name = "jack"
def deco(name):
def f(fun):
def h(*args, **kwargs):
print("decorator", name, fun.__name__)
return fun(*args)
return h
return f
@deco(name)
def fun1(a, b):
print("fun1")
return
@deco(name)
def fun2(a, b):
print("fun2")
return
@deco(name)
def fun3(a, b):
print("fun3")
return
#li = [fun1,fun2,fun3]
#for f in li:
if __name__ == '__main__':
fun3(1, 2)
fun1(2, 3)
python 装饰器传参数
最新推荐文章于 2023-12-23 10:46:54 发布