def logging(level): def wrapper(func): def inner_wrapper(*args, **kwargs): print(level + ": enter function " + func.__name__) return func(*args, **kwargs) return inner_wrapper return wrapper @logging(level='INFO') def say(something): print("say {}!".format(something)) if __name__ == '__main__': say('hello') m = logging(level='INFO')(say) m('hello')
上面直接使用@和下面调用结果不应该是一样的吗?可结果明显不一样