例如:def main():
if something == True:
player()
elif something_else == True:
computer()
def player():
# do something here
check_winner() # check something
computer() # let the computer do something
def check_winner():
check something
if someone wins:
end()
def computer():
# do something here
check_winner() # check something
player() # go back to player function
def end():
if condition:
# the player wants to play again:
main()
elif not condition:
# the player doesn't want to play again:
# stop the program
# whatever i do here won't matter because it will go back to player() or computer()
main() # start the program
我的问题是,如果某个条件成立(在函数check_winner中)并执行函数end(),它将返回到computer()或player(),因为没有线条告诉计算机停止执行player()或computer ()。你如何在Python中停止函数?