from functools import wraps
from functools import time
def func(any_fuc):
@wraps(any_fuc)
def func2(*args,**kwargs):
print('this is functions run time')
any_fuc(*args,**kwargs)
return func2
@func
t1 = time.time()
def new_func(a,b):
return a+b
print(new_func(1,3))
t2 = time.time()
print(t2-t1)
@func
t1 = time.time()
def new_func(a,b):
return a+b
print(new_func(1,3))
t2 = time.time()
print(t2-t1)
错误:
File "main.py", line 13
t1 = time.time()
^
SyntaxError: invalid syntax