#!/usr/bin/env python #-*- coding:utf-8 -*- # Author:DCC import time def timer(func): def deco(*args,**kwargs): # def warpper(*args,**kwargs): start_time = time.time() func(*args,**kwargs) 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(3) print("in the test1") @timer # test2 = timer(test2) =deco def test2(name,age): print(name,age) print("in the test2") test1() test2("dcc","25")