您好,我正在使用eclipse和pydev,我想知道为什么我的示例代码在尝试使用while函数时无法工作。
print("Welcome to the annoying program")
response = ""
while response != "Because.":
response = input("why\n")
print("Oh,ok")输出如下:
Welcome to the annoying program
why
Because.
Traceback (most recent call last):
File "/Users/calebmatthias/Document/workspace/de.vogella.python.first/simpprogram.py", l ine 9, in <module>
response = input("why\n")
File "/Users/calebmatthias/Desktop/eclipse 2/plugins/org.python.pydev_2.2.3.2011100616/PySrc/pydev_sitecustomize/sitecustomize.py", line 210, in input
return eval(raw_input(prompt))
File "<string>", line 1
Because.
^
SyntaxError: unexpected EOF while parsing发布于 2011-10-15 06:21:42
2.x中的input函数将输入计算为Python代码!请改用raw_input函数。
对于input,你的文本是“因为。”,这是一个语法错误,因为点后面没有任何东西。
https://stackoverflow.com/questions/7774183
复制相似问题