Python 输入()导致;扫描字符串文字时下线“;错误

Python 输入()导致;扫描字符串文字时下线“;错误,python,python-3.x,input,syntax,Python,Python 3.x,Input,Syntax,我目前正试图在Python3.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

我目前正试图在Python3.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!")
answer=input(“要查找结果,请按enter。”)
#问题是,我不知道我没有遵循哪种符号或Python规则
而答案==():
打印(“你是父亲!”)

当需要字符串作为输入时,您希望使用
原始输入
input
作为python表达式进行计算。

为什么您认为
而answer==()
在python中有任何意义?我建议您学习Python教程,以便掌握语法的窍门

如果我理解您的要求,您可以删除该行:

answer = input("to find out your result, press enter.")
print("You are the father!")

调用
input
将停止任何其他操作,直到按下enter键。

我很确定您实际上没有使用Python 3(除非您是2017年的用户,我猜Python 3.4.7可能会发布)。Python 2中对
input()
的输入被执行(
input(prompt)
=
eval(raw\u input(prompt))
),当它只是一个空字符串时,会导致一个
SyntaxError

win32上的Python 2.7.9(默认值,2014年12月10日,12:28:03)[MSC v.1500 64位(AMD64)] 有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。 >>>输入('你好?') 你好 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 文件“”,第0行 ^ SyntaxError:分析时出现意外的EOF

使用
raw\u input()
通常是您想要的。Python3中删除了旧的
input()
,取而代之的是旧的
raw\u input()。您只需要
answer=input(…);打印(…)
while answer==():
毫无意义。包含错误,而不仅仅是说“类似于EOL扫描文字的东西”会更有帮助。这仅适用于Python 2。问题标题指定这是Python3。@sweeneyrod问题标题指定(指定)Python3.4.7,它不存在(3.4.3将在大约一周后发布)。我想提问者不知道他在用什么版本。我是2017年的;)