Python:有什么方法可以在Word文档中添加脚注吗? [英] Python: Is there a way I can add a footnote to word document?
本文介绍了Python:有什么方法可以在Word文档中添加脚注吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已尝试使用python-docx进行以下操作:
I have tried the following with python-docx:
section = self.document.sections[0]
footer = section._sectPr.footer
footer.text = "I am here"
我在docx文档中找不到清晰的页脚/页眉说明.是否可以解决这个问题?
I couldn't find a clear footer/header directions in docx documentations. Is there a work around to cover this gap?
推荐答案
解决方法是:
- 使用python-docx创建一个文档.
- 将名称更改为"init.docx"
- 注释所有添加新样式的代码
- 打开'init.docx'
- 删除所有内容
- 保存.
- 在"init.docx"中添加脚注/标题
- 将
self.document = Document('')
更改为self.document = Document('init.docx')
.
这篇关于Python:有什么方法可以在Word文档中添加脚注吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文