【发布时间】:2017-01-12 12:39:53
【问题描述】:
我已经开始为 Absolute Beginners 3e 开发著名的 Python。我一直在忠实地复制代码,但有些人如何不断收到错误消息。因此,我使用了 help/examples 文件夹中提供的代码,但仍然收到相同的消息:
Traceback (most recent call last):
File "word_problems.py", line 6, in <module>
input("Press the enter key to find out.")
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
谁能给我一个线索,或者解释什么不起作用。我也可以贴出部分代码,其余部分相同(但我想很多人都知道这本书),但有不同的问题:
print("If a 2000 pound pregnant hippo gives birth to a 100 pound calf,")
print("but then eats 50 pounds of food, how much does she weigh?")
input("Press the enter key to find out.")
print("2000 - 100 + 50 =", 2000 - 100 + 50)
【问题讨论】:
-
那是因为您使用的是
python 2。试试raw_input() -
重点是,你应该升级你的Python版本;毫无疑问,您以后会遇到其他不一致的地方。
-
更新到哪一个?我使用的是 Python 2.7,我有几门课程建议使用该版本,因为他们使用的是旧程序。