#-*-coding:utf-8-#coding=utf-8
__author__ = 'ffyanga'import time
#无参数修饰符defcounttime(fun):def_wrapper(*args,**kwargs):
starttime = time.clock()
fun(*args,**kwargs)
print"%s cost %f second"%(fun.__name__,time.clock()-starttime)
return _wrapper
#有参数修饰符deflog(text):defdecorator(fun):defwrapper(*args,**kwargs):print"%s %s()"%(text,fun.__name__)
return fun(*args,**kwargs)
return wrapper
return decorator
@counttimedefcheckio():for i in range(1):
print'this is a %d example!'%i
#time.sleep(1)@counttimedefnewtest(id=0):print"new id =%d"%id
@log("参数")defcheckto(box):print"this is a has parameter %s"%box
if __name__ =='__main__':
#checkio()
newtest()
newtest(2)
#checkto("pig")