我正在学习 Python,下面是一个包含 while 循环的 Python 游戏函数,但是这个循环作为一个无限循环工作,我无法理解它是如何工作的以及它应该如何工作。
谁能帮我解释一下while循环的含义,以及“bear_move=False”变量和循环条件“WHILE TRUE”之间的关系。我无法理解这个 while 循环结构和条件,以及这个 while 循环条件与什么相关。
def bear_room():
print "There is a bear here."
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move the bear?"
bear_moved=False
while True: #What is this while loop means here
next=raw_input("You should write take honey or taunt bear: >")
if next=="take honey":
print "The bear looks at you then pimp slaps your face off."
elif next=="taunt bear" and not bear_moved:
print "The bear has moved from the door. You can go through it now."
bear_moved=True
elif next=="taunt bear" and bear_moved:
print "The bear gets pissed off and chews your crotch off."
elif next=="open door" and bear_moved:
gold_room()
else:
print "I got not I dea what that means."