装饰器-2

[root@node110 decorator]# cat temp.py

#!/usr/bin/env python

import time

def sayhi():

  print 'hi yoursister...'

  time.sleep(0.1)

 

def time_counter(func):

  def wrapper():

    start =time.time()

    func()

    end =time.time()

    print 'Thisfunction costs:',end-start

  return wrapper

 

sayhi=time_counter(sayhi)

sayhi()

 


分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS