xlrd excel工作表读取错误“open_workbook()得到意外的关键字参数'on'u demand'”

2024-10-01 13:40:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用xlrd从excel工作表读取单元格值。我的代码如下,它以前工作得很好,但不知道在xlrd包中发生了什么变化,我得到了错误

“TypeError:open_workbook()获得意外的关键字参数'on'u demand'”

from xlrd import open_workbook
bench = open_workbook('excelsheet.xls',on_demand=True)
for name in bench.sheet_names():
    sheetnew = bench.sheet_by_name(name)
    for i in range(0, 13):
        for cell in sheetnew.col(i):
            print cell.value
    bench.unload_sheet(name)

Tags: 代码nameinforon错误cellopen
1条回答
网友
1楼 · 发布于 2024-10-01 13:40:34

这解决了我的问题。可能对某人有帮助。在

from xlrd import open_workbook
bench = open_workbook("excelsheet.xls")
for name in bench.sheet_names():
    sheetnew = bench.sheet_by_name(name)
    for i in range(0, 13):
        for cell in sheetnew.col(i):
            print cell.value

相关问题 更多 >