如何使用xlrd打开xlsx文件

问题描述 投票:0回答:1

我正在尝试使用 xlrd 模块打开 xlsx 文件。代码是这样的:

    workbook = xlrd.open_workbook('DAT_XLSX_EURUSD_M1_2018.xlsx')

但是我这个错误:

    AttributeError: module 'xlrd' has no attribute 'xlsx'

建议使用下面的代码来防止发生此错误形式,但是,它没有帮助

    xlrd.xlsx.ensure_elementtree_imported(False, None)
    xlrd.xlsx.Element_has_iter = True

我的xlrd版本是2.0.1

python python-3.x xlsx xlrd
1个回答
0
投票

显然,xlrd 2.0.1 版本不支持 xlsx 文件,但可以使用 xls 文件。我下载了 xlrd 1.2.0,它打开了我的 xlsx 文件,没有任何错误。

© www.soinside.com 2019 - 2024. All rights reserved.