Header and footer creation in versions before 0.8.8
问题 Is there a workaround for adding headers and footers in a Microsoft Word ( docx ) file? These are not implemented in versions of python-docx prior to 0.8.8 . More specifically, I would like to add: Page number to footers Some random text to headers The ideal code will look as follows: from docx import Document document = Document() # Add header and footer on all pages document.save("demo.docx") 回答1: How about something like this (Thanks to Eliot K) from docx import Document import win32com