推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
pharaoh21c
V2EX  ›  Python

xlwt 一直显示 AttributeError: 'Sheet' object has no attribute 'write'

  •  
  •   pharaoh21c · Jul 6, 2018 · 15522 views
    This topic created in 3008 days ago, the information mentioned may be changed or developed.
    python 版本 3.6,windows7,我已经安装了 xlrd 和 xlwt 模块,为何在执行下方代码时一直显示:
    AttributeError: 'Sheet' object has no attribute 'write'

    多谢高手指点!

    代码如下:
    "
    import xlrd
    import xlwt

    bo1=xlrd.open_workbook(r'C:\extest01.xlsx')
    she1=bo1.sheets()[0]
    she1.write(0,10,"string")
    "
    4 replies  •  2018-07-06 21:46:15 +08:00
    saulshao
        1
    saulshao  
       Jul 6, 2018
    你那个是读...你都没用 xlwt 这个模块,只是引入了一下,读一下文档吧。
    我建议换用那个新版的,好像叫 openxl 还是啥来着
    pharaoh21c
        2
    pharaoh21c  
    OP
       Jul 6, 2018
    @saulshao 谢谢!我百度了很久,好像就是用这个语法的,搞不懂。另外那个是说 openpyxl 么,我也在同步尝试。。。
    saulshao
        3
    saulshao  
       Jul 6, 2018
    你不能用 xlrd.open,应该用 xlwt.open 或者啥的。
    换句话说,前面那个是只读打开,后面那个打开的文件才会有写方法
    相关的文档有完整的实例
    pharaoh21c
        4
    pharaoh21c  
    OP
       Jul 6, 2018
    @saulshao 多谢指点~~~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   934 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:16 · PVG 07:16 · LAX 16:16 · JFK 19:16
    ♥ Do have faith in what you're doing.