标签:auth 地址 知识 python running close 其他 用法 装饰器
1 def func1(test): 2 def deco(): 3 #progress 4 return deco#返回函数的地址,达到不改变调用方式的目的
完整程序:
# __Author__Panda-J____ import time def timer(func): # for test1 & 2 start_time = time.time() func() # run func and test its running time end_time = time.time() print("this func running time is %s" % (end_time - start_time)) return func @timer def test1(): time.sleep(1) print("this is test1") @timer def test2(): time.sleep(1) print("this is test2") test1() test2()
标签:auth 地址 知识 python running close 其他 用法 装饰器
原文地址:http://www.cnblogs.com/BigJ/p/7396144.html