使用python-docx通过文档结构检索文档内容 [英] Retrieve document content with document structure with python-docx
本文介绍了使用python-docx通过文档结构检索文档内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须从 docx
文件中检索表和上一个/下一个段落,但是无法想象如何使用 python-docx
I have to retrieve tables and previous/next paragraphs from docx
file, but can't imagine how to obtain this with python-docx
我可以通过 document.paragraphs
我可以通过 document.tables
我如何获得像这样的文档元素的有序列表
How can I get an ordered list of document elements like this
[
Paragraph1,
Paragraph2,
Table1,
Paragraph3,
Table3,
Paragraph4,
...
]?
推荐答案
解析为属性Document.story,按文档顺序包含段落和表格
Resolved as property Document.story, contains paragraphs and tables in document order
https://github.com/python-openxml/python-docx/pull/395
document = Document('test.docx')
document.story
这篇关于使用python-docx通过文档结构检索文档内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文