小编Rob*_*ley的帖子

docx-python word doc 分页符

我正在尝试使用 docx-python 库在文档中间添加分页符。

似乎在添加分页符时,分页符被添加到文档的末尾。有没有一种方法可以将分页符添加到特定位置?

这是我目前的代码。

from docx import Document
from docx.shared import Inches

demo='gm.docx'
document = Document(docx=demo)

for paragraph in document.paragraphs:
    if 'PUB' in paragraph.text:
        document.add_page_break()

document.save('gm.docx')
Run Code Online (Sandbox Code Playgroud)

python split python-docx

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

标签 统计

python ×1

python-docx ×1

split ×1