import time str1 = 'aaaaa' def run_timefunc(func): def new_func(*args,**kwargs): t0 = time.time() func() # back = func(*args,**kwargs) print('函数运行时间%s'%(time.time()-t0)) return return new_func() @run_timefunc def com3(): for i in range(0,10000000): type('aaa') @run_timefunc def com2(): for i in range(0,10000000): isinstance('aaa',str) com3() com2()