word模板填值

1、手动做好模板——my_test.docx的内容:

我的名字叫做{{ name }}。

2、python代码:

# test_fill_word.py
# python -m pip install docxtpl

from docxtpl import DocxTemplate

tpl = DocxTemplate('my_test.docx')

context = {
   'name': 'lovecjy'
}

tpl.render(context)
tpl.save('my_test1.docx')

运行上述代码,会在脚本所在目录生成填好数据word——my_test1.docx。

python——word模板中填值

以上。

相关文章:

  • 2022-02-20
  • 2022-02-19
  • 2022-12-23
  • 2021-07-06
  • 2021-11-17
  • 2022-12-23
  • 2021-09-07
  • 2022-01-13
猜你喜欢
  • 2021-11-17
  • 2021-06-18
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案