python 爬取的数据导出到excel
pip install xlwings
安装这个包,然后网上找使用说明。该包在PYTHON中简直可当成EXCEL的外挂了,可实时从EXCEL中读取单元格中的数据,也可实时将数据传递到EXCEL中显示。
怎么用python读取excel表格的数据
# 需安装 xlrd-0.9.2 和 xlutils-1.7.1 这两个模块
from xlwt import Workbook, Formula
import xlrd
book = Workbook()
sheet1 = book.add_sheet('Sheet 1')
sheet1.write(0,0,10)
sheet1.write(0,1,20)
sheet1.write(1,0,Formula('A1/B1'))
sheet2 = book.add_sheet('Sheet 2')
row = sheet2.row(0)
row.write(0,Formula('sum(1,2,3)'))
row.write(1,Formula('SuM(1;2;3)'))
row.write(2,Formula("$A$1 $B$1*SUM('ShEEt 1'!$A$1:$b$2)"))
book.save('formula.xls')
book = xlrd.open_workbook('formula.xls')
sheet = book.sheets()[0]
nrows=sheet.nrows
nc