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中的数值的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

anaconda和Python区别

Python的关键字有哪些

Python输出hello world代码的方法

java与Python中单例模式的区别

Python os.chown() 方法是什么?它有什么样的作用?

深入了解Python之xml操作

Python判断变量的类型吗

Python中pip是什么

Python做并行计算可以吗

Python中关于executemany以及序列的实例详解

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




打赏

取消

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

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

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

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

评论

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