Discuss / Python / 发现一个问题

发现一个问题

Topic source

叫小小兽

#1 Created at ... [Delete] [Delete and Lock User]
def log(func):
    def warpper(x, y):
        print("call %s():" % func.__name__)
        func(x, y)
    return warpper

@logdef add_num(x, y):
    return x + y

print(add_num(10, 20))

使用装饰器之后,原来的函数return的值为什么变成了None?

call add_num():
None
def warpper(x, y):
        print("call %s():" % func.__name__)
        func(x, y)

这里没有返回值,默认返回None


  • 1

Reply