python读取excel
来源:互联网 发布:显示网络存在安全隐患 编辑:程序博客网 时间:2024/05/18 02:48
模块:xlrd
可以pip install xlrd
打开一个excel:
table = xlrd.open_workbook(filename)
获取一个sheet
first_sheet = table.sheets()[0] # orfirst_sheet = table.sheet_by_index(0) # orfirst_sheet = table.sheet_by_name(u'Sheet1')
获取一个表的行数和列数
row = sheet_object.nrowscol = sheet_object.ncols
代码
import xlrddef open_excel(path): table = None try: table = xlrd.open_workbook(filename=path, encoding_override='utf-8') except Exception as error: print('[-]error in open_excel()', error) finally: return tabledef get_sheet_by_index(excel, index): try: return excel.sheet_by_index(index) except Exception as error: print('[-]error in get_sheet()', error)def output_sheet(sheet): row = sheet.nrows col = sheet.ncols for i in range(row): if i == 0: continue for j in range(col): if j == 0: continue print(int(sheet.row_values(i)[j]), end=' ') print()path = 'C:/Users/Administrator/Desktop/workcall.xlsx'table = open_excel(path=path)first_sheet = get_sheet_by_index(excel=table, index=0)output_sheet(sheet=first_sheet)
写操作等我用到了再来继续添加
0 0
- python读取excel
- python 读取excel --zhaokuo719
- python 读取excel
- python读取EXCEL
- python读取excel
- python 读取Excel
- Python excel文件读取
- 用python读取excel
- Python 读取excel
- python读取excel文件
- python读取excel文件
- python 读取不规则excel
- python读取excel数据
- python读取excel数据
- python 读取excel数据
- python读取excel文件
- python读取excel数据
- python读取Excel
- 独立游戏开发日记(1)
- tar打包 解压
- 有关v$asm_attribute视图的一点记录
- 【安卓逆向】如何不用设置debuggable="true"就可以动态调试
- 从零开始学算法(四)搜索算法(二)(广度优先搜索)
- python读取excel
- EditText的imeOptions属性的使用
- 嵌入式linux永不关闭屏幕
- 复制复杂(多指针)链表
- JavaScropt基础
- 页面性能优化的利器—Timeline
- PHP开发记录
- mysql UNIX时间戳与日期的相互转换
- OpenDaylight-Boron学习笔记:1 实验环境搭建说明