import time
def time(func):
print(time.ctime())
return func()
@time # 从这里可以看出@time 等价于 time(xxx()),但是这种写法你得考虑python代码的执行顺序
def xxx():
print('Hello world!')
函数首行不需要缩进
import time
def time(func):
print(time.ctime())
return func()
@time # 从这里可以看出@time 等价于 time(xxx()),但是这种写法你得考虑python代码的执行顺序
def xxx():
print('Hello world!')
函数首行不需要缩进