Python 3.7, EOFError: EOF when reading a line

Python 3.7, EOFError: EOF when reading a line

我无法 运行 我的代码,我正在使用 atom.iopython 3.7。这是我的代码:

num1 = input("enter a number: ")
num2 = input("enter another number: ")
result = int(num1) + int(num2)
print(result)

一直这样说:

enter a number: Traceback (most recent call last):
  File "C:\Users\icebergnes\Desktop\CODE\Calculator Basic.py", line 2, in <module>
    num1 = input("enter a number: ")
EOFError: EOF when reading a line

当像 input() 或 raw_input() 这样的 built-in 函数在遇到其输入流末尾之前未读取任何数据时,会引发 EOFError。

尝试使用 try except 看看它是否有效。

try:
   #your code

except EOFError as e:
   print(e)