文档
- https://docxtpl.readthedocs.io/en/latest/
- https://pypi.org/project/docxtpl/
- https://github.com/elapouya/python-docx-template
安装
pip install docxtpl
示例
from docxtpl import DocxTemplate
doc = DocxTemplate("template.docx")
context = { 'name' : "Tom" }
doc.render(context)
doc.save("doc.docx")
模板语法类似Jinja2
文件模板 template.docx
{{name}}
渲染后的结果 doc.docx
Tom