在工作中经常会对excel进行数据处理,一般常用模块式xlrd、xlwt、xlutils。
以下是xlrd、xlwt、xlutils模块的简单介绍xlrd - 读取 Excel 文件
xlwt - 写入 Excel 文件
xlutils - 操作 Excel 文件的实用工具,如复制、分割、筛选等
安装pip install xlrd
pip install xlwt
pip install xlutils
xlrd 读取excelexcel = xlrd.open_workbook('demo.xlsx')
table = excel.sheet_by_index(0)
print(u"表单 %s 共 %d 行 %d 列" % (table.name, table.nrows, table.ncols))
print("第一行第二列:", table.cell_value(0, 1))
ncols = table.ncols # 获取列表的有效列数
print('获取列表的有效列数-->', ncols)
print('获取指定行的所有数据-->', table.row_values(1))
print('获取指定列的所有数据-->', table.col_values(1))
参考链接:
http://blog.csdn.net/liu5257/article/details/53864198