问题描述
def decoratorrt(func):
def innerht():
print("hello there")
func()
print("it has ended")
return innerht
@decoratorrt
def hellot():
print("hello","are you in")
hellot()
我收到的错误消息是TypeError Traceback(最近一次通话最近) 在 ----> 1 hellot()
解决方法
您缩进了return innerht
;应该是decoratorrt
的返回值,但是如果没有返回值,decoratorrt
会隐式返回None
(而innerht
会试图返回自身)。固定功能:
def decoratorrt(func):
def innerht():
print("hello there")
func()
print("it has ended")
return innerht # Dedented