运行代码:
import csv
import xlwt
workbook = xlwt.Workbook()
sheet2 = workbook.add_sheet("Sheet 2", cell_overwrite_ok=True)
file = open(r'D:\label.csv')
lines = csv.reader(file)
r = 0
for line in lines:
col = 0
for c in line:
sheet2.row(r).write(col,c, style=xlwt.Style.default_style)
#print(c,end=' ')
col += 1
r += 1
sheet2.flush_row_data()
file.close()
workbook.save("csv2excel.xlsx")