凌的博客

您现在的位置是: 首页 > 学无止境 > python > 

python

python 带参数装饰器

2021-08-06 python 812
def say_hello(country):
    def wrapper(func):
        def deco(*args, **kwargs):
            print(country)
            func(*args, **kwargs)
        return deco
    return wrapper

@say_hello('china')
def test():
    print("hello test")


test()

返回结果:

china

hello test


文章评论

0条评论