-1
file_name = files.blobstore.create(mime_type='application/ms-excel', _blobinfo_uploaded_filename='sample.xls')
wbk = xlwt.Workbook()
sheet = wbk.add_sheet('Sheet 1')
stringa = str(newfile.text)
s3 = stringa.split('\n')
i=1
for riga in s3:
s2=riga.split()
try:
x = float(s2[0])
y = float(s2[1])
sheet.write(i, 1, '%g' %x)
sheet.write(i, 2, '%14.3e' %y)
except:
sheet.write(i, 1, '%s' %s2[0])
sheet.write(i, 2, '%s' %s2[1])
i=i+1
파일 "/base/data/home/apps/s~marco-busso/1.357756583016056739/helloworld.py", 라인 (140), '% s'% s2 [0]) IndexError : 목록 색인이 범위를 벗어났습니다.색인 목록 오류 Google 앱 엔진
왜?
감사 :
오류를 방지하기 위해, 당신은 등의if
문에서 루프 본문을 포장 할 수 있습니까? – user1281174물론. 예를 들어'for' 루프의 내용을'if riga :'문으로 감쌀 수 있습니다. –
예제를 추가했습니다. –