import sys
def carton(x):
bottle=x/10
rem=x%10
if rem > 7:
bottle = bottle + rem + 1
elif rem == 7:
bottle = bottle + 1
elif 5<rem<7:
bottle = bottle + 2
elif rem == 5:
bottle = bottle + 1
elif rem<5:
bottle = bottle + rem
print (bottle)
def carton_small(x):
bottle = 0
if x > 7:
bottle = bottle + x%7 + 1
elif x == 7:
bottle = bottle + 1
elif 5<x<7:
bottle = bottle + 2
elif x == 5:
bottle = bottle + 1
elif x<5:
bottle = x
print(bottle)
while True:
test = sys.stdin.read()
try:
test = int(test)
except ValueError:
print ("no, wrong data")
continue
except EOFError:
print ("no,EOF")
continue
if not test: break
break
for x in range(test):
while True:
bottle = sys.stdin.read()
try:
bottle = int(bottle)
except ValueError:
print ("no, wrong data")
continue
except EOFError:
print ("no, EOF1")
continue
if not test: break
break
if(bottle>10):
carton(bottle)
elif(bottle<10):
carton_small(bottle)
else:
bottle = 1
print (bottle)
我编写了代码来检查送奶工需要携带x升牛奶的最小瓶数。瓶子的尺寸仅为{1,5,7,10}升。事情在我的系统上工作正常,但在Ideone上,我无限地得到我的valueError异常中定义的错误.Anyhelp可能吗? 我确定问题是因为sys.stdin.readline()在这里输入做得很好但是ideone不接受input()我想。