#------------------------------------------------使用类当做装饰器------------------------------------------------------- # def check(func): # def inner(): # print("登录验证") # func() # return inner class check: def __init__(self, func): self.f = func def __call__(self, *args, **kwargs): print("登录验证") self.f() @check def fashuoshuos(): print("发说说") # 这样写与@check是相同的。 # fashuoshuos = check(fashuoshuos) fashuoshuos()
python核心编程-方法相关补充-使用类当做装饰器
最新推荐文章于 2024-05-19 23:52:56 发布