当前位置: 首页 > 图灵资讯 > 行业资讯> python处理Excel的方法之xlrd

python处理Excel的方法之xlrd

发布时间:2025-09-23 10:55:37

python处理excel常用的模块是xlrd。使用xlrd处理excel文档非常方便。以下是基本用法

打开文件

importxlrd
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)

行数、列数等

nrows=table.nrows
ncols=table.ncols

单元格数据

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#0empty,1string,2number,3date,4bool,5eroror
value='thisiscellvalue'
xf=0

相关文章

Python中reduce函数和lambda表达式的学习

Python中reduce函数和lambda表达式的学习

2025-09-25
Python小白必学的面向对象

Python小白必学的面向对象

2025-09-25
一个例子解释python装饰器

一个例子解释python装饰器

2025-09-25
深入理解Python的set和dict

深入理解Python的set和dict

2025-09-25
Python中正则表达式的巧妙使用

Python中正则表达式的巧妙使用

2025-09-25
5分钟搞定Python中函数的参数

5分钟搞定Python中函数的参数

2025-09-25