标签:oop 取整 enc write 出错 写入内容 table excel pre
读取
1、导入模块
import xlrd
2、打开Excel文件读取数据
data = xlrd.open_workbook(‘excel.xls‘)
3、获取一个工作表
1 table = data.sheets()[0] #通过索引顺序获取 2 table = data.sheet_by_index(0) #通过索引顺序获取 3 table = data.sheet_by_name(u‘Sheet1‘)#通过名称获取
workbook = xlwt.Workbook(encoding = ‘ascii‘)
3、创建表
worksheet = workbook.add_sheet(‘My Worksheet‘)
sheet.write(0,0,‘test‘)
sheet.write(0,0,‘oops‘)
会出错,添加上面代码cell_overwrite_ok=True可解除
worksheet.write(0, 0, label = ‘Row 0, Column 0 Value‘)
workbook.save(‘Excel_Workbook.xls‘)
标签:oop 取整 enc write 出错 写入内容 table excel pre
原文地址:http://www.cnblogs.com/vhills/p/7398469.html