目前,我想要写在Python 3.4.7块运行如果输入材料是输入。但是,当我按下回车键,显示以下错误信息:
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!")
你要期待字符串作为输入时使用raw_input
。 input
评估为一个python表达。
为什么你认为while answer == (<<Enter>>)
意味着在Python什么?我建议做一个Python教程,让你可以在语法的窍门。
如果我理解你想要什么,你可以删除该行:
answer = input("to find out your result, press enter.")
print("You are the father!")
到input
呼叫停止别的发生压,直到进入。
我敢肯定你没有真正使用Python 3(除非你在2017年的时候,当我猜的Python 3.4.7可能被释放)。在Python 2所述的输入到input()
被执行(input(prompt)
= eval(raw_input(prompt))
),并且当它只是一个空字符串,它会导致一个SyntaxError
:
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> input('Hello?')
Hello?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
使用raw_input()
通常是你想要的。在Python 3中除去旧input()
老raw_input()
了它的位置。