class BaseRoute(object): def __init__(self, path): print(path) def __call__(self, func): def _wrapper(pagems): print("func params", pagems) print(func.__name__) return _wrapper route = BaseRoute(path="/User") @route def test(params): pass if __name__ == '__main__': params = {"name": "唐昊"} test(params) # /User # func params {'name': '唐昊'} # test
python类装饰器
最新推荐文章于 2025-04-04 23:39:01 发布