0


解决Python TypeError: ‘NoneType‘ object is not callable

import time

def get_time(fn):
    def inner():
        start = time.time()
        fn()
        end = time.time()
        print(f'{fn}函数打印100000用了{end-start}s')
    return inner()   # 这里的'()'会导致报错'NoneType' object is not callable
                      # 只要去掉inner后面的括号即可解决问题

@get_time
def func1():
    # i = 1
    # while i < 100000 :
    #     i += 1
    #     print(i)
    for i in range(100001):
        print(i)

func1()
标签: python

本文转载自: https://blog.csdn.net/m0_45145990/article/details/119762782
版权归原作者 m0_45145990 所有, 如有侵权,请联系我们删除。

“解决Python TypeError: ‘NoneType‘ object is not callable”的评论:

还没有评论