问题
I have tried the following with python-docx:
section = self.document.sections[0]
footer = section._sectPr.footer
footer.text = "I am here"
I couldn't find a clear footer/header directions in docx documentations. Is there a work around to cover this gap?
回答1:
The work around is:
- Create a document with python-docx.
- Change the name to 'init.docx'
- Comment any adding-new-style code
- Open 'init.docx'
- Delete everything
- Save it.
- Add footnote/Headers to 'init.docx'
- Change
self.document = Document('')
toself.document = Document('init.docx')
.
来源:https://stackoverflow.com/questions/38795791/python-is-there-a-way-i-can-add-a-footnote-to-word-document