新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python處理Excel的方法之xlrd
python處理Excel常用到的模塊是xlrd。使用xlrd可以非常方便的處理Excel文檔,下面介紹一下基本用法

創(chuàng)新互聯(lián)公司主要從事網(wǎng)站設(shè)計制作、做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)筠連,10余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
打開文件
import xlrd
data= xlrd.open_workbook("c:\\skills.xls")獲取一個工作表
table = data.sheet_by_name(u'skills') #也可以 table = data.sheet_by_index(0)
行,列的獲取
table.row_values(i) table.col_values(i)
行數(shù),列數(shù)等
nrows = table.nrows ncols = table.ncols
單元格數(shù)據(jù)
cell_A1 = table.cell(0, 0).value cell_C4 = table.cell(2, 3).value
簡單寫單元格
table.put_cell(row, col, ctype, value, xf) row = col = 0 ctype = 1 # 0 empty , 1 string, 2 number, 3 date, 4 bool, 5 error value = 'this is cell value' xf = 0
網(wǎng)頁名稱:創(chuàng)新互聯(lián)Python教程:python處理Excel的方法之xlrd
標題來源:http://m.5511xx.com/article/cdgdpeg.html


咨詢
建站咨詢
