Python中生成(写入数据到)Excel文件 by xlwt

import xlwt
    wb = xlwt.Workbook();
    ws = wb.add_sheet('report');
    ws.write(0, 0, "max_len="+str(result2[0]));
    ws.write(0, 1, "max_lev="+str(result2[1]));
    ws.write(0, 2, "min_len="+str(result2[2]));
    ws.write(0, 3, "min_lev="+str(result2[3]));
    ws.write(0, 4, "sum_len="+str(result3[0]))
    ws.write(0, 5, "sum_lev="+str(result3[1]));
    ws.write(0, 6, "url_1="+url_1);
    ws.write(0, 7, "url_2="+url_2);
    ws.write(2, 0, "time_num");
    ws.write(2, 1, "data1");
    ws.write(2, 2, "data2");
    ws.write(2, 3, "len");
    ws.write(2, 4, "lev");
    for index in range(len(result1)):
        ws.write(3+index,0,str(result1[index][0]))
        ws.write(3+index,1,str(result1[index][1]))
        ws.write(3+index,2,str(result1[index][2]))
        ws.write(3+index,3,str(result1[index][3]))
        ws.write(3+index,4,str(result1[index][4]))
    wb.save(start_time+"-"+end_time+" report.xls");

你可能感兴趣的:(python)