python怎么读取excel中的数值


当前第2页 返回上一页

根据Excel中sheet名称读取数据:  

1

2

3

4

5

6

7

8

9

10

import xlrd

def readExcelDataByName(fileName, sheetName):

    table = None

    errorMsg = None

    try:

        data = xlrd.open_workbook(fileName)

        table = data.sheet_by_name(sheetName)

    except Exception, msg:

        errorMsg = msg 

    return table, errorMsg

根据Excel中sheet的序号获取:

1

2

3

4

5

6

7

8

9

10

import xlrd

def readExcelDataByIndex(fileName, sheetIndex):

    table = None

    errorMsg = ""

    try:

        data = xlrd.open_workbook(fileName)

        table = data.sheet_by_index(sheetIndex)

    except Exception, msg:

        errorMsg = msg

    return table, errorMsg

更多Python相关技术文章,请访问Python教程栏目进行学习!

以上就是python怎么读取excel中的数值的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

Python合法标识符要求是什么

Python中有栈吗

Python的int是什么

Python中选择排序的实例详解

Python如何连接mysql

Python字典中如何添加键值对

mac自带Python在哪

Python自定义对象实现切片功能的介绍(代码示例)

Python以什么划分句块

Python归一化多维数组的方法

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...