- 帖子
- 18
- 精华
- 0
- 积分
- 116
- 阅读权限
- 20
- 注册时间
- 2017-7-25
- 最后登录
- 2018-11-6
|
报错与代码如下,请问怎么解决
f = open('score.txt')
lines = f.readlines()
#print (lines)
results = []
for line in lines:
#print (line)
data = line.split()
sum = 0 #print (data)
for fenshu in data[1:]:
sum += int(fenshu)
result = '%s \t: %d\n' %(data[0], sum)
#print (result)
results.append(result)
#print (results)
output = open('result.txt', 'w')
output.writelines(results)
output.close()
报错 list index out of range error 但是我是在看不出来哪里超出list范围了
|
|