Python xlrd.Book: how to close the files?

≡放荡痞女 提交于 2019-11-29 04:06:19
deeenes

In case you open a workbook with on_demand = True for a more economic resource use (see here how does it work), you need to call release_resources() method at the end. As a minimal example:

import xlrd

book = xlrd.open_workbook('workbook.xls', on_demand = True)
sheet = book.sheet_by_index(0)
data = [[str(c.value) for c in sheet.row(i)] for i in xrange(sheet.nrows)]
book.release_resources()
del book
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!