zoukankan      html  css  js  c++  java
  • python_62_装饰器5

    import time
    def timer(func): #timer(test1)  func=test1
        def deco(*args,**kwargs):
            start_time=time.time()
            func(*args,**kwargs)   #run test1()
            stop_time = time.time()
            print("the func run time  is %s" %(stop_time-start_time))
        return deco
    @timer  #test1=timer(test1)
    def test1():
        time.sleep(1)
        print('in the test1')
    
    @timer # test2 = timer(test2)  = deco(内存地址)  test2(name) =deco(name)
    def test2(name,age):
        print("test2:",name,age)
    
    test1()
    test2("alex",22)
    

      

  • 相关阅读:
    RabbitMQ
    Java 多线程
    Java 多线程
    Java 多线程
    Java 多线程
    Springboot
    SpringBoot
    SpringCloud Config
    Financial
    Hystrix
  • 原文地址:https://www.cnblogs.com/tianqizhi/p/8376677.html
Copyright © 2011-2022 走看看