#!/usr/bin/env python3
from functools import wraps
import time
def decor1(param):
'''
支持@decor1、@decor1('text')调用
'''
def is_func():
func = param
@wraps(func)
def wrapper1(*args, **kw):
print('call start')
ts = time.time()
res = func(*args, **kw)
te = time.time()
print('call end')
print('run time:%s s'% (te -ts))
return res
return wrapper1
def is_str():
text = param
def text_deco(func):
@wraps(func)
def wrapper1(*args, **kw):
print(text)
print('call start')
ts = time.time()
res = func(*args, **kw)
te = time.time()
print('call end')
print('run time:%s s'%(te - ts
装饰器decorator
最新推荐文章于 2024-04-20 10:39:13 发布