你好是使用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
請修復您的代碼格式化,並確保它反映了究竟你有什麼。空格在Python中很重要。 –
它看起來像是在混合來自Python 2.X和Python 3.X的代碼。這個代碼的腳本是哪個版本的? – thefragileomen