EOF错误python 3?

时间:2016-05-16 20:01:11

标签: python python-3.x

我在python 3中不断收到EOF错误。这是我的代码

num = float(input()) #servings
p = float(input()) #people
a2 = float(input())
b2 = float(input())
c2 = float(input())
d2 = float(input())
e2 = float(input())
f2 = float(input())
g2 = float(input())
h2 = float(input())
i2 = float(input())
a1 = a2 / num
b1 = b2 / num
c1 = c2 / num
d1 = d2 / num
e1 = e2 / num
f1 = f2 / num
g1 = g2 / num
h1 = h2 / num
i1 = i2 / num
a = a1 * p
b = b1 * p
c = c1 * p
d = d1 * p
e = e1 * p
f = f1 * p
g = g1 * p
h = h1 * p
i = i1 * p
lis = str(a)+ str(b)+ str(c)+ str(d)+ str(e)+ str(f)+ str(g)+ str(h)+   str(i)
print (lis) #8 14 1 1 6 2 1 2 .5 2

并且错误在第11行。如果我删除第11行以及随之而来的所有代码,它会在第10行,然后是9,然后是8等时给出错误。

1 个答案:

答案 0 :(得分:1)

代码正常工作,直到您提供 11个输入值,因为有 11个输入语句。如果您没有提供足够的输入,则会发生EOF错误。我假设最后一行的评论是您的输入,它只有 10个值。我认为这是 EOF错误的原因。