为什么我在input()得到一个EOFerror。split()?

时间:2018-03-26 00:30:33

标签: python

为什么我在input().split()收到了EOFerror?

teams = {}

count = 0

n = int(input())

while (count < n):
    t1, t2, p1, p2 = input().split()

    p1 = int(p1)
    p2 = int(p2)


    if (t1 not in teams):
        teams[t1] = 0

    if (t2 not in teams):
        teams[t2] = 0

    #if home team wins
    if (p1 > p2):
        teams[t1] += (p1 + 3000)
        teams[t2] += (p2 + 50)

    #if away team wins
    if (p1 < p2):
        teams[t1] += (p1 + 50)
        teams[t2] += (p2 + 3500)

    #if teams draw
    if (p1 == p2):
            teams[t1] += (p1 + 1000)
            teams[t2] += (p2 + 1000)

count += 1          


print(max(teams, keys=teams.get)) 

print(min(teams, keys=teams.get))

1 个答案:

答案 0 :(得分:0)

递增count在循环外部完成,因此它在循环内始终保持为0,因此您继续读取太多。

缩进语句,使其位于while

之下