无参:
import  time
def show_time(f):        #装饰器函数
    def inner():         #闭包函数
        stat = time.time()
        f()
        end = time.time()
        print('spend %s' % (end - stat))
    return inner
@show_time  #相当于foo = show_time(foo)
def foo() :              #原始函数
    print('foo....')
    time.sleep(2)
foo()
有参:
import  time
def show_time(f):        #装饰器函数
    def inner(*x,**y):         #闭包函数
        stat = time.time()
        f(*x,**y)
        end = time.time()
        print('spend %s' % (end - stat))
    return inner
@show_time  #foo = show_time(foo)
def foo(*a,**b):
    sums = 0
    for i in a:
        sums += i
    print(sums)
    time.sleep(1)
foo(1,2,3,4)