编辑:下面是一个更复杂的示例的简化代码。
def lottery(amount, callback=None):
print(f'You spent {amount} on a lottery ticket.')
if callback:
callback(amount)
def win(amount):
print(f'You won ${amount * 1000}!!!')
def lose(amount):
print(f"Sorry, you spent {amount} and didn