我正在尝试使第二个打印语句等待,直到在命令行中按Enter键,但我仍然收到意外的EOF错误。
print "hi"
continu = input("Press Enter to continue!")
print "hi"
这是我的回溯
Traceback (most recent call last):
File "save_cookies.py", line 2, in <module>
continu = input("Press Enter to continue!")
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
最佳答案
看来您正在混合python2
和python3
语句。
对于python2
,您需要使用raw_input
(PEP 3111):
print "hi"
raw_input("Press Enter to continue!")
print "hi"
对于
python3
,您需要调整print
(PEP 3105)的语法:print("hi")
input("Press Enter to continue!")
print("hi")