今天开始学习《python编程快速上手》中的第12章:处理Excel电子表格。但是遇到了点小问题。

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

import openpyxl
wb = openpyxl.load_workbook('example.xlsx')
sheet = wb.get_sheet_by_name('Sheet1')
print(sheet.get_highest_row())
D:\>python test.py
test.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两个方法。

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

欢迎关注我公众号【小众技术】,此公众号专注分享Python、爬虫学习资料和干货,关注后回复【PYTHON】,无套路免费送你一个学习大礼包,包括爬虫视频和电子书~

Python错误:AttributeError: 'Worksheet' object has no attribute 'get_highest_row' 解决办法相关推荐

  1. Python错误:AttributeError: 'generator' object has no attribute 'next'解决办法

    今天在学习生成器对象(generation object)运行以下代码时,遇到了一个错误: #定义生成器函数 def liebiao(): for x in range(10): yield x #函 ...

  2. python 错误AttributeError: ‘dict_keys‘ object has no attribute ‘sort‘

    当运行Python代码时,出现以下错误: AttributeError: 'dict_keys' object has no attribute 'sort' 当代码有sort函数时,检查其他代码都没 ...

  3. 使用face_recognition模块:错误AttributeError:'PngStream' object has no attribute 'chunk fcWp'

    使用face_recognition模块:错误AttributeError:'PngStream'object has no attribute 'chunk fcWp' 文章目录: 一.错误:Att ...

  4. 求助!spyder beautifulsoup4显示错误:AttributeError: 'HTMLParserTreeBuilder' object has no attribute 'initia

    spyder beautifulsoup4显示错误: AttributeError: 'HTMLParserTreeBuilder' object has no attribute 'initia 实 ...

  5. pytorch 错误 AttributeError: ‘Tensor‘ object has no attribute ‘backword‘

    pytorch 错误 AttributeError: 'Tensor' object has no attribute 'backword' 按错误说明是没有backword属性. 错误代码 loss ...

  6. 【Python】AttributeError: ‘DatetimeProperties’ object has no attribute ‘weekday_name’ 的解决方法

    运行下面的代码: import pandas as pd# 创建日期 dates = pd.Series(pd.date_range("2/2/2002", periods=3, ...

  7. AttributeError: 'NoneType' object has no attribute 'sc' 解决方法(二)

    上一次本以为可以解决了这个问题,然而并没有那么地简单.博主最近在edx网站学习pyspark,想打一下视频上的代码,结果报错了,依旧是报了"AttributeError:'NoneType' ...

  8. Python 中 AttributeError: ‘NoneType‘ object has no attribute ‘X‘ 错误

    文章目录 AttributeError: 'NoneType' object has no attribute 'X' 介绍 AttributeError: 'NoneType' object has ...

  9. python pandas AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘

    python使用pandas DataFrame.ix的时候 AttributeError: 'DataFrame' object has no attribute 'ix' 在使用进行DataFra ...

最新文章

  1. 实战分享:淘宝Web 3D应用与游戏开发
  2. [转]ECMAScript 6 入门 -编程风格
  3. phpcms v9调用指定栏目名称、url、图片、描述等
  4. HBase get查询命令及VERSIONS版本
  5. ResourceLoader 获取资源
  6. Mysql中group by 使用中发现的问题
  7. linux网络编程:使用多进程实现socket同时收发数据
  8. java 邮件模板_Spring Boot 2发送邮件手把手图文教程
  9. MySQL8.0数据库配置注意事项
  10. 2017年最受欢迎的15大Python库有哪些?
  11. Redis的高级应用-事务处理、持久化、发布与订阅消息、虚拟内存使用
  12. java动态规划求最大子段和_动态规划-最大子段和
  13. 【Linux】ssh的安装及配置
  14. python九九乘法表代码中的i+1的意思_python---九九乘法表代码
  15. 【GamePlay】Unity手机屏幕UI适配问题
  16. STM32中的串口通信的基础知识
  17. 手机平台强制进下载模式方式
  18. 宏观经济学_宏观经济指标
  19. python云盘搭建教程_超简单!基于Python搭建个人“云盘”,目前最好用的个人云盘...
  20. docker registry http api v2(原创请注明出处)

热门文章

  1. 命令行参数是什么?如何去使用它?
  2. 2018驾考宝典面试总结
  3. “重口味”海报引发热议,LG V6000 Plus冰箱如何诠释“精准营销”?
  4. 2012互联网开发应该关注的
  5. 华秋约定您!7月11-13日慕尼黑上海电子展不见不散~
  6. 机器学习中正则化技术
  7. 党政机关安全信息资源系统
  8. jeesite,jeeplus,jeeng,jeebase技术交流
  9. naive 路由使用 loadingBar 进度条
  10. 4、Latex学习笔记之数学公式篇