因此...
这有效
def makeBold(fn):
def wrapped():
return '<b>'+fn()+'</b>'
return wrapped
@makeBold
def sayhello():
return 'Ey yo wassup'
并产生预期的 Ey yo wassup
然而,这不起作用
def makeBold(fn):
def wrapped():
return '<b>'+fn()+'</b>'
return wrapped
def makeItalic(fn):
def wrapped():
return '<i>'+fn()+'</i>'
@makeItalic
@makeBold
def sayhello():
return 'Ey yo wassup'
哪一个都产生了这个漂亮的NoneType错误...
我认为它会产生类似 Ey yo wassup
的东西思想?
答案 0 :(得分:0)
def makeBold(fn):
def wrapped():
return '<b>'+fn()+'</b>'
return wrapped
def makeItalic(fn):
def wrapped():
return '<i>'+fn()+'</i>'
return wrapped
@makeItalic
@makeBold
def sayhello():
return 'Ey yo wassup'