python 未指定输入个数时进行输入

python take input when number of input is not specified

我是 python 的新手,正在尝试解决 SPOJ 中的问题,

在这个问题中没有指定输入的数量(指定了最大 10,怎么可能是 1 到 10 之间的任何值) 因此它给出了 NZEC 错误

我试过这个:

t = 10
while(t>0):
   t = t - 1 
   n = raw_input()
   if(len(n) == 0):
      break

但是没用

在 c 中我们可以使用 EOF 来确定这个

请帮忙

已解决 使用

try:
   while True:
       n = int(raw_input())
       #do something
except:
   pass