标签:span code color test fun int app time() 装饰器
import time def timmer(func): def wrapper(): start_time = time.time() func() stop_time=time.time() print(‘test函数运行时间为%s‘%(stop_time-start_time)) return wrapper @timmer def test(): time.sleep(1) print(‘test函数运行完毕‘) test() ----运行结果 test函数运行完毕 test函数运行时间为1.0002305507659912
标签:span code color test fun int app time() 装饰器
原文地址:https://www.cnblogs.com/Forever77/p/9912270.html