python xlrd库报错AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘

1.首先报错原因是xlrd版本过高,需要卸载,下载低版本的库:降低第三方库xlrd的版本至1.2.0。
https://www.cnblogs.com/hls-code/p/15715697.html
2.降低版本后还会报错:AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘
报错原因:在新版python3.9中,windows中使用的更新删除了getiterator方法,所以我们老版本的xlrd库调用getiterator方法时会报错。
将xlsx.py文件中的所有getiterator()替换成iter()。解决

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AttributeError: 'ElementTree' object has no attribute 'getiterator' 是一个错误消息,它表示在使用某个方法时发生了属性错误。根据引用和引用的内容,这个错误通常在使用较旧版本的xlrd与较新版本的Python解释器时发生。在新版Python 3.9中,Windows中的更新删除了getiterator方法,因此使用旧版本的xlrd时会报错。 为了解决这个问题,你可以尝试以下方法: 1. 更新xlrd:首先,确保你使用的是最新版本的xlrd,可以使用pip命令来更新它。在命令行中运行以下命令:`pip install --upgrade xlrd` 2. 使用其他方法替代getiterator:由于getiterator方法已被删除,你可以尝试使用其他方法来遍历ElementTree对象的元素。例如,你可以使用iter方法来替代getiterator方法。具体的代码实现可能因你的具体情况而有所不同,但你可以参考引用中的示例代码来进行修改。 总结起来,要解决AttributeError: 'ElementTree' object has no attribute 'getiterator'的问题,你可以更新xlrd或者使用其他方法替代getiterator方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [已解决AttributeError: ‘ElementTreeobject has no attribute ‘getiterator‘异常的正确解决方法,亲...](https://blog.csdn.net/weixin_50843918/article/details/129741536)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [AttributeError: ‘ElementTreeobject has no attribute ‘getiterator‘问题解决,亲测有效](https://blog.csdn.net/likunpengjiayou/article/details/125545209)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值