问题
I am new to python and trying to solve a problem in SPOJ ,
In this question number of input(maximum 10 is specified, how ever it could be anything between 1 to 10) is not specified hence it gives NZEC error
I tried this:
t = 10
while(t>0):
t = t - 1
n = raw_input()
if(len(n) == 0):
break
but it does not work
in c we can use EOF to determine this
please help
回答1:
Solved Use
try:
while True:
n = int(raw_input())
#do something
except:
pass
来源:https://stackoverflow.com/questions/38621513/python-take-input-when-number-of-input-is-not-specified