from docxtpl import DocxTemplate, InlineImage filename = './template2.docx' doc = DocxTemplate(filename) context = { "版次": "edition", "零件号": "0", } doc.render(context) output_filename = './modified_template.docx' doc.save(output_filename)