Python操作excel文件
工具: xlrd, xlwt
安装:pip命令安装即可
使用:
读 xlrd
import xlrd book = xlrd.open_workbook(filename) sheet1 = book.sheet_by_index(0) for row in range(sheet1.nrows): for col in range(sheet1.ncols): print(sheet1.cell_value(row, col))
写 xlwt
import xlwt wb = xlrd.Workbook() ws = wb.add_sheet("Sheet1") ws.write(0,0,"hello") ws.write(0,1,"world") wb.save('example.xls')
KEEP LEARNING!