import time
def timeit(f):#f = myfunc(8)
def wapper(x):
start = time.time()
f(x)
ret = (time.time()-start)
return ret
return wapper
@timeit
def myfunc(x):
time.sleep(x)
print(myfunc(8))
提问:wapper的x是怎么传进来的
看看这个,慢慢瞅,一步一步的理解
https://www.runoob.com/w3cnote/python-func-decorators.html