我现在的代码是这样的:importxlwtimportxlrdfromxlutils.copyimportcopymyyear='2018'myweek='10'mycd='1001'fileName=myyear+myweek+'.xls'workbook=xlwt.Workbook(encoding='UTF-8'...
我现在的代码是这样的:import xlwtimport xlrdfrom xlutils.copy import copymyyear = '2018'myweek = '10'mycd='1001'fileName = myyear + myweek + '.xls'workbook = xlwt.Workbook(encoding='UTF-8')worksheet = workbook.add_sheet('sheet1')worksheet.write(0, 0, label='year')worksheet.write(0, 1, label='week')worksheet.write(0, 2, label='CD')worksheet.write(0, 3, label='keyword')worksheet.write(0, 4, label='importance')savePath = r'D:/' + fileNameworkbook.save(savePath)rexcel = xlrd.open_workbook(savePath)rows = rexcel.sheets()[0].nrowsexcel = copy(rexcel)worksheet = excel.get_sheet(0)current_row = rowsfor cmp_noun, value in [[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10],[11,11],[12,12],[13,13],[14,14]]: if current_row<=5: worksheet.write(current_row, 0, label=myyear) worksheet.write(current_row, 1, label=myweek) worksheet.write(current_row, 2, label=mycd) worksheet.write(current_row, 3, label=cmp_noun) worksheet.write(current_row, 4, label=value) current_row += 1excel.save(savePath)我想要的实际效果是这样下图这样的的:请问我怎么修改代码能达到每5行放到一个sheet里?
展开