打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Python错误:AttributeError: ''Worksheet'' object has no attribute ''get

当我按照书中的方法获取最大行和最大列的时候,出现了下面的错误提醒:

import openpyxlwb = openpyxl.load_workbook('example.xlsx')sheet = wb.get_sheet_by_name('Sheet1')print(sheet.get_highest_row())
D:\>python test.pytest.py:5: DeprecationWarning: Call to deprecated function get_sheet_by_name (Use wb[sheetname]).sheet = wb.get_sheet_by_name('Sheet1')Traceback (most recent call last):File "test.py", line 12, in <module>print(sheet.get_highest_row())AttributeError: 'Worksheet' object has no attribute 'get_highest_row'print(sheet.get_highest_row())AttributeError: 'Worksheet' object has no attribute 'get_highest_row'

 

书中提到的获取最大行的方法是:get_highest_row(),获取最大列的方法是:get_highest_row()。

多次比对书中的代码后发现,语法上没有任何错误。于是我就去Google了一下,在stackoverflow中找到了答案()

https://stackoverflow.com/questions/37849980/openpyxl-no-attribution-error

原来,get_highest_row()和get_highest_column()在最新版的openpyxl模块中已经被删除了,取而代之的是max_row和max_column两个属性。

注意:使用的时候不用在方法后面添加括号。 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
AttributeError: 'Worksheet' object has no attribute 'iter_columns'
成功解决 class 'AttributeError' : 'Editor' object has no attribute '_Editor__markerMap'
Tensorflow AttributeError: 'NoneType' object has no attribute 'TF_DeleteStatus'
教你用Python自动读取数据生成图表,产生的效益很可观
Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法 | 大爱
python attribute lookup
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服