def openTest():
print('open 13232')
def closeTest():
print('close bza')
from functools import wraps
def hint(open=openTest,close=closeTest):
def wrapper(func):
@wraps(func)
def inner_wrapper(*args, **kwargs):
open()
res=func(*args, **kwargs)
close()
return res
return inner_wrapper
return wrapper
@hint()
def hello():
print('hello')
hello()
实际view
@hint()
def test(request):
print("fafaf")
return JsonResponse({"code":200,"msg":"ok"},status=200)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)