day11_ decorator

 

Time Import 

DEF FUNC (): 
    the time.sleep ( 0.01 ) 
    Print ( " refueling " ) 
DEF Timer (F): # decorator function 
    DEF Inner (): 
        Start = the time.time () 
        F () function decorated # 
        End = time.time () 
        Print (End - Start)
     return Inner 

FUNC = the Timer (FUNC) 
FUNC () 
# does not modify the original function call, but before and after the original function to add functionality
#timer a decorator is just a function of a function there are some decorative effect

 

Guess you like

Origin www.cnblogs.com/wzc27229/p/10992053.html