Revision decorator

Import Time # 
#
# DEF index ():
# the time.sleep (. 3)
# Print ( 'available for purchase to China')
# DEF Timmer (FUNC):
# Inner DEF ():
# = Start the time.time ()
# FUNC ( )
# = the time.time STOP ()
# Print ( '% S IS RUN Time'% (STOP - Start))
# Inner return
#
# Timmer = index (index)
# index ()
'' '
available for purchase to China
RUN IS Time 3.0002970695495605
'' '
# decorator syntax: decorative objects in the row directly above write a decorator name alone on the @
# Import Time
# DEF Timmer (FUNC):
# DEF Inner ():
# = time.time Start ()
# FUNC ( )
# = time.time STOP ()
Print # ( 'IS RUN Time S%'% (STOP - Start))
# return Inner
# @timmer # @ decorator to being below the function name as a parameter passed to the decorator @ name, and the results rename the index
DEF index # ():
# the time.sleep (. 3)
# Print ( 'available for purchase to China')
#
# index ()
'' '
available for purchase to China
RUN Time IS 3.000959634780884
' ''
# Import Time
# DEF Timmer (FUNC):
Inner DEF # ():
# = Start the time.time ()
# RES = FUNC ()
# = the time.time STOP ()
# Print ( '% S IS RUN Time'% (STOP - Start))
# return RES
# return Inner
# @timmer
# DEF index ():
# the time.sleep (. 1)
# Print ( 'Welcome to China')
# return 521
#
# res=index()
# print(res)
'''
Welcome to China
run time is 1.0006263256072998
521
'''
# import time
# def timmer(func):
# def inner(*args,**kwargs):
# start = time.time()
# res=func(*args,**kwargs)
# stop = time.time()
# print('run time is %s' % (stop - start))
# return res
# return inner
# @timmer
# def home(name):
# print('Welcome %s to China'%name)
#
# home('Rambo')
'''
Welcome Rambo to China
run time is 0.0
'''
# There are parameters decorator
# import time
# def auth(func):
# # func=index
# def inner(*args,**kwargs):
# name=input('>>:name').strip()
# password=input(">>:paseword").strip()
# if name == "Rambo" and password == '123':
# print('登录成功')
# return func(*args,**kwargs)
# else:
# print('用户名或者密码错误')
# return inner
# @auth
# def index(name):
# time.sleep(1)
# print('Welcome %s to China'%name)
# return 521
#
# res=index('Rambo')
# print(res)

Guess you like

Origin www.cnblogs.com/0B0S/p/11979341.html