在我点击“输入”之前,Python IDLE 2.7将不会执行文件

时间:2013-03-06 21:56:15

标签: python python-idle

出于某种原因,当我选择“运行模块”时,IDLE将不会运行第一行代码,直到我按“enter”。对于这种类型的程序来说这不是一个大问题,但我很困惑为什么会发生这种情况。任何人都可以为我清除这个吗?这是代码:

print("Please think a number between 0 and 100!")
guess = 50
upper = 100
lower = 0
status = ""
while status != "c":
    print("Is your secret number ") + str(guess) + ("?")
    print ("Lower: ") + str(lower)
    print ("Upper: ") + str(upper)
    status = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate     the guess is too low. Enter 'c' to indicate I guessed correctly. ")
    if status == "h":
        upper = guess
        guess = guess - (guess - lower)/2
    elif status == "l":
        lower = guess
        guess = guess + (upper - guess)/2
    elif status == "c":
        break
    else:
    print("Sorry, I did not understand your input.")
print("Game over. Your secret number was: ") + str(guess)

非常感谢!

1 个答案:

答案 0 :(得分:1)

http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/execution.html(见1.9.2节)。如果之前的程序被中断,有时会发生错误。