循环操作后的python3 EOFError,有异常

时间:2017-07-18 12:00:31

标签: python python-3.x input

以下是我的python 3代码,在第7行我得到了一个错误异常如下,是否有人可以帮助我? 提前谢谢

Exception Name: EOFError
Exception Message: EOF when reading a line
Exception Line number: 7
5     B = []
6     C = []
7     A = [int(x) for x in input().split()]
8     B = [int(x) for x in input().split()]
9     for index in range(N):

我改变了我的代码,因为如果其中一个列表为null,则会出现异常

def sum_c(arr):
    for index_C in arr:
        if index_C != arr[-1]:
            print(index_C, end=' ')
        else:
            print(index_C)


N = int(input())
while N != 0:
    A = []
    B = []
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    if len(A) == 0 and len(B) != 0:
        sum_c(B)
    elif len(A) != 0 and len(B) == 0:
        sum_c(A)
    else:
        sum_c([sum(x) for x in zip(A, B)])
    N -= 1

1 个答案:

答案 0 :(得分:0)

您的程序在调用input()时预期输入,但提供的标准输入已达到结束(或可能为空)。

您根本没有提供输入。