报错module 'xlrd' has no attribute 'open_workbook'以及 python No such file or directory: 'results.xls'

import xlrd失败

data=xlrd.open_workbook('results.xls') 失败

报错:AttributeError: module 'xlrd' has no attribute 'open_workbook'

我的原因:发现创建的py文件名叫 xlrd.py ,这样导致在文件中找open_workbook方法,改文件名成xlrdtest.py,成功


但是,



接着,报错:   python No such file or directory: 'results.xls'

我的原因,results文件格式是csv,改格式为xls

成功

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
AttributeError: partially initialized module 'xlrd' has no attribute 'open_workbook'是因为xlrd模块没有open_workbook属性。 这个错误通常是由于导入模块时的循环导入导致的。循环导入指的是两个或多个模块相互导入对方,从而形成一个循环。在这种情况下,Python解释器会认为模块只是部分初始化,因此无法找到特定的属性或函数。 要解决这个问题,可以尝试以下几个方法: 1. 检查你的代码,确保没有发生循环导入。循环导入通常是由于模块之间的相互依赖关系未正确处理而导致的。 2. 确保你的模块已经正确安装并可用。你可以尝试重新安装xlrd模块来解决可能的安装问题。 3. 如果你使用的是Python2,请确保你使用的是xlrd模块的正确版本。有时候模块的不同版本可能会引起属性错误。 4. 如果以上方法都不起作用,你可以尝试使用另一个类似的模块,比如openpyxl,来处理Excel文件。 希望这些方法能帮助你解决AttributeError的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [AttributeError: partially initialized module ‘‘ has no](https://blog.csdn.net/qq_43511299/article/details/117333975)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [会说话的代码 Python pyttsx3,及AttributeError:partially initialized module......(......)报错,解决...](https://blog.csdn.net/LiuYaLiu2/article/details/123411204)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [求解报错AttributeError:module ‘os’ has no attribute ‘exit’](https://download.csdn.net/download/weixin_38590309/14856609)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值