推荐学习书目
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
shawnma
V2EX  ›  Python

[小白求助] Python 操作 Excel 的小问题

  •  
  •   shawnma · Apr 3, 2020 via iPhone · 2257 views
    This topic created in 2274 days ago, the information mentioned may be changed or developed.
    大佬们,怎么用 openpyxl 模块实现在同一个单元格内主动换行写入?
    4 replies    2020-04-03 22:56:53 +08:00
    renmu
        1
    renmu  
       Apr 3, 2020 via Android
    字符串里加一个\n 试试?
    shawnma
        2
    shawnma  
    OP
       Apr 3, 2020 via iPhone
    @renmu 非常感谢回答,试过了,木有用…
    renmu
        3
    renmu  
       Apr 3, 2020 via Android   ❤️ 1
    我找到了这个,你可以试试,可以在 Stack Overflow 搜这个:Writing multi-line strings into cells using openpyxl 。
    我发不出来链接。
    worksheet.cell('A1').style.alignment.wrap_text = True
    worksheet.cell('A1').value = "Line 1\nLine 2\nLine 3"
    shawnma
        4
    shawnma  
    OP
       Apr 3, 2020 via iPhone
    @renmu 多谢指点,问题解决了~~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   880 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:29 · PVG 04:29 · LAX 13:29 · JFK 16:29
    ♥ Do have faith in what you're doing.