3-13 装饰器

 

3-13 装饰器

3-13 装饰器

 


 

3-13 装饰器

 

import time
def fun(bian):   ###装饰器
    def fun_1():  ##定义
        start_time = time.time()
        bian()
        stop_time = time.time()
        print('it is run %s'%(stop_time-start_time))
    return fun_1
@fun      ##调用装饰器  也等于 aa = aa(fun)
def aa():
    time.sleep(3)
    print('it is in aa')

aa()
View Code

相关文章:

  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-09-25
  • 2021-05-29
猜你喜欢
  • 2021-04-16
  • 2021-09-09
  • 2022-02-06
  • 2021-08-06
  • 2022-12-23
  • 2021-11-18
  • 2021-05-17
相关资源
相似解决方案