相关疑难解决方法(0)

创建word文档时出现python-docx style_id错误

我正在按照python-docx网站上提供的教程创建一个MS-Word文档但是我收到一个错误:

M:\Sites>python word.py
C:\Program Files\IBM\SPSS\Statistics\22\Python\lib\site-packages\docx\styles\sty
les.py:54: UserWarning: style lookup by style_id is deprecated. Use style name a
s key instead.
  warn(msg, UserWarning)
Run Code Online (Sandbox Code Playgroud)

word.py

    from docx import Document
    from docx.shared import Inches
    import json

    document = Document()

    document.add_heading('Document Title', 0)

    p = document.add_paragraph('A plain paragraph having some ')
    p.add_run('bold').bold = True
    p.add_run(' and some ')
    p.add_run('italic.').italic = True

    document.add_heading('Heading, level 1', level=1)
    document.add_paragraph('Intense quote', style='IntenseQuote')

    document.add_paragraph(
        'first item in unordered list', style='ListBullet'
    )
    document.add_paragraph(
        'first item in ordered list', …
Run Code Online (Sandbox Code Playgroud)

python ms-word python-2.7 python-docx

6
推荐指数
1
解决办法
3941
查看次数

标签 统计

ms-word ×1

python ×1

python-2.7 ×1

python-docx ×1