TypeError: 'NoneType' object is not callable

TypeError: 'NoneType' object is not callable

 None类型不是一个可以可以调用(callable)对象

赋值语句错误,值为None

callable对象是指一个后面可以加()的对象,一般把调用函数时()去掉

函数例子

def use_logging(func):
    def wrapper(*args,**kwargs):
        logging.warning("%s is runing" % func.__name__)
        return func(*args)
    return wrapper()

@use_logging
def foo():
    print('i am foo')
#@use_logging
def bar():
    print('i am bar')

bar = use_logging(bar)
bar
或者

@use_logging

def bar():
    print('i am bar')
bar
 

 

posted @ 2020-11-24 17:23  hanjianfei  阅读(1335)  评论(0编辑  收藏  举报