我正在创建一个程序,读取
文件和if文件的第一行
是不是空白,它读下四个
行。计算在
这些线,然后下一条线是
阅读。< / p >
像这样的东西应该工作:
for line in infile:
next_lines = []
if line.strip():
for i in xrange(4):
try:
next_lines.append(infile.next())
except StopIteration:
break
# Do your calculation with "4 lines" here
>>> int('55063.000000')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '55063.000000'