输入("按Enter继续......"):SyntaxError:解析时意外的EOF

时间:2017-08-15 16:03:13

标签: python

我有一个简单的代码:

#!/usr/bin/env python                                                                                                                                                                                       
import sys
print (sys.version)

list = ["cat", "dog", "horse", "duck"]
for animal in list:
    if animal == "cat" or animal == "duck":
        print animal
        input("Press Enter to continue ...")

print (sys.version)的输出是

2.7.11 (default, Dec 19 2016, 17:44:19) 
[GCC 5.3.0]

但是,按 Enter 后,程序在input("Press Enter to continue ...")行崩溃,表示错误

SyntaxError: unexpected EOF while parsing

为什么会发生这种情况?

此问题与How do I make python to wait for a pressed key

有关

0 个答案:

没有答案