所以我是业余程序员,我想为一些基于文本的黑客游戏做些功能。其中,将会调用一个函数来让玩家找到战利品等等。所以我正在做一些“小规模测试”; 在我的测试过程中,我发现如果我有一个函数(它内部调用了一个不同的函数),那么一些文本被“打印”,第二个函数将被首先调用。延迟函数调用 - Python
#Example using a sort of 'Decorator'.
def Decor(func):
print("================")
print("Hey there")
print("================")
print("")
func
def Hello():
print("And HELLO WORLD!")
decorated = Decor(Hello())
decorated
但产量始终是沿着线的东西:
And HELLO WORLD!
================
Hey there
================
有没有一种方法,使文本后调用该函数打印? 或者简单地延迟被调用的函数。 或者我正在做这个错误的方式? 谢谢你的时间。
请注意'装饰'是'无',你最后的声明没有效果... –