【python】【excel读写 模块】

 
 

读取:

 
 
#author Reid
#date 2017-11-11
#function read from xls file
#! usr/bin/python
import os
import xlrd
import xlwt


data = xlrd.open_workbook('relation.xls')
table = data.sheet_by_index(0)
mrows = table.nrows    #rows
mcols = table.ncols    #cols

print mrows
for row in range(mrows):
    for col in range(mcols):
        value = table.cell(row,col)
        print value



f = xlwt.Workbook()  
sheet1 = f.add_sheet(u'sheet1', cell_overwrite_ok=True)  
sheet1.write(0,0,'some text')  
f.save('test1.xls')
 
 
 

猜你喜欢

转载自blog.csdn.net/spy20008/article/details/78525224