【发布时间】:2019-01-05 01:17:54
【问题描述】:
def decorator_function(original_func):
def wrapper_func():
print('Run this code before the function that needs docorated')
original_func()
print('Run this code after the function that needs decorated has been called')
return wrapper_func()
def function_needing_decorated():
print('I need to be decorated')
decorator_test = decorator_function(function_needing_decorated)
我猜这与对 return 的误解有关,因为我很确定我不应该添加括号。我的问题是为什么它不起作用?为什么它是 NoneType 但不是 NoneType 当我不放括号时。您对此越详细越好,因为我真的需要了解这一点。
【问题讨论】:
标签: python return python-decorators nonetype