[英]How to Retrieve a particular section from docx file using python docx2txt module
我正在使用 python docx2txt模块来处理 docx 文件。现在我可以通过使用这个模块来获取整个文档。但我的要求是逐节检索文档(例如单独使用其内容的标题)。请帮助我获取使用 docx2txt 库的特定部分或标题。
The docx2text
module has no built-in function for that. docx2text
模块没有内置函数。
That means you have a couple of options.这意味着你有几个选择。
docx
file using the zipfile
module.zipfile
模块打开docx
文件。 Then read the word/document.xml
file from the zipfile and extract the information.word/document.xml
文件并提取信息。 This will give you the complete XML structure, so it should be possible to recognize section headers.python-docx
, like in this question .python-docx
,就像在这个问题中一样。 All computerized processing requires that the documents have a consistent internal structure.所有计算机化处理都要求文件具有一致的内部结构。 If you have a document that uses real section headers but also formatted lines to start a section, your conversion is bound to fail.
如果您的文档使用真实的部分标题但也使用格式化的行来开始一个部分,那么您的转换肯定会失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.