我在解析包含图像的文档中的文本时遇到问题。
我在运行Ubuntu 12.04.4 LTS(GNU / Linux 3.2.0-60-generic x86_64)的Ubuntu Linux机器上使用Python docx的0.7.0版
我正在使用此逻辑:
```
document = Document(path)
# Get all paragraphs
paras = document.paragraphs
text = ""
# Push the text from the paragraph on a single string
for para in paras:
# Don't forget the line break
text += "\n" + para.text
return text.strip()
```
当有图像时,此过程失败。
我做错什么了吗?
python-docx
应该支持您在这里尝试做的事情。如果您提供堆栈跟踪信息,则在出现错误时会得到提示,我来看一下。
顺便说一句,您可以将其编码为:
document = Document(path)
text = '\n'.join([para.text for para in document.paragraphs])
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句