函数返回值是-函数名

#高阶函数应用2:把函数名当作参数传给高阶函数,高阶函数直接返回函数名
import time
def foo():
print('from the foo')

def timmer(func):
start_time=time.time()
return func
stop_time=time.time()
print('函数%s 运行时间是%s'%(func,stop_time-start_time))
foo=timmer(foo)
foo()
#总结:我们确实没有改变foo的调用方式,但是我们也没有为foo增加任何新功能



显示结果: from the foo
原文地址:https://www.cnblogs.com/huangjinshan/p/6144286.html