【发布时间】:2015-02-17 16:58:30
【问题描述】:
我目前正在尝试在 Python 3.4.7 中编写一个块,如果输入的材料是 Enter,则该块会运行。但是当我按 Enter 时,它会显示以下错误消息:
SyntaxError: EOL while scanning string literal
一些示例代码:
answer = input("to find out your result, press enter.")
# Problem is here, I don't know what kind of sign or Python rule I'm not following
while answer == (<<Enter>>):
print("You are the father!")
【问题讨论】:
-
对
input的调用不会结束,直到您按 Enter。您只需要answer = input(...); print(...)。while answer == (<<Enter>>):毫无意义。 -
包含错误,而不是仅仅说“类似 EOL 扫描文字”会更有帮助。
标签: python python-3.x input syntax