python装饰器给被装饰函数新增方法

# -- coding: utf-8 --
import time

time_count=0



def zsq(fun):
    class T():
        def __init__(self,*args,**kwargs):
            print('开始')
            self.T=fun(*args, **kwargs)
            print('结束')
        def start(self):
            print('start',self.T)
        def __call__(self, *args, **kwargs):
            # self.T
            ...

    return T




@zsq
def add(x, y):
    global time_count
    st=time.time()
    time.sleep(1)

    et=time.time()-st
    time_count+=et
    print(f'{x} + {y} 的结果是 {x + y}','耗时 ',time_count)
    return x+y

add(1,2).start()
搜索