【发布时间】:2019-04-13 01:07:45
【问题描述】:
最近,python-docx 的版本0.8.8 添加了对headers and footers 的直接支持。
现在可以简单地添加页眉或页脚,如下所示:
from docx import Document
document = Document()
header = document.sections[0].header
header.add_paragraph('This is an example Header')
footer = document.sections[0].footer
footer.add_paragraph('This is an example Footer')
在此版本之前,可以使用template approach 灵活地添加页眉和页脚。
使用模板可以非常简单地包含页码等内容。但是,新版本中页眉和页脚的实现似乎并非如此。
在0.8.8 及更高版本中添加页码是否有简单的方法?
【问题讨论】:
标签: python python-3.x python-docx