python 写入数据

import sys
reload(sys)
sys.setdefaultencoding('utf8') import xlrd
import xlwt
book = xlrd.open_workbook('C:/Users/13717/Desktop/sg.xls')
sheet = book.sheet_by_index(0) book1 = xlwt.Workbook() #创建文件
sheet1 = book1.add_sheet('test',cell_overwrite_ok=True)#创建工作部对象
print sheet.nrows,sheet.ncols
for i in range(sheet.nrows):
print sheet.row(i)[1].value
if sheet.row(i)[1].value == '河北':
for j in range(0,10):
sheet1.write(i,j,sheet.row(i)[j].value) #根据行号写内容 book1.save('test.xls')
上一篇:log4net记录系统错误日志到文本文件用法详解(最新)


下一篇:ligureUI 刷新列求和