我不了解raw_input

时间:2017-02-17 15:25:56

标签: python while-loop

loop_flag = 1
 while loop_flag == 1:
    choice = raw_input("Enter 'quit' to Exit the loop: ")
    if choice == 'quit':
     loop_flag = 1
    else:
       print ("Keep Going")

我遇到了这个raw_input的问题 消息是

  Traceback (most recent call last):
 File "C:\Users\Exemm\Downloads\TNCC\ITN_260_Network_security_basics\Week 6                                 02.13 – 02.19\Lab 1 - Copy (4)\ts.py", line 4, in <module>
    choice = raw_input ("Enter 'quit' to Exit the loop: ")
  *NameError: name 'raw_input' is not defined**

1 个答案:

答案 0 :(得分:1)

loop_flag = 1
while loop_flag == 1:
    choice = raw_input("Enter ‘quit’ to Exit the Loop: ")
    if choice == "quit":
        loop_flag = 0
    else:
        print "Keep Going"