通过python读取Docx文件 [英] Read Docx files via python

查看:50
本文介绍了通过python读取Docx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道一个python库来读取docx文件吗?

Does anyone know a python library to read docx files?

我有一个Word文档,我正试图从中读取数据.

I have a word document that I am trying to read data from.

推荐答案

python-docx可以读写.

python-docx can read as well as write.

doc = docx.Document('myfile.docx')
allText = []
for docpara in doc.paragraphs:
    allText.append(docpara.text)

现在所有段落都将在列表allText中.

Now all paragraphs will be in the list allText.

感谢Al Sweigart提出的如何使用Python自动完成无聊的工作".

Thanks to "How to Automate the Boring Stuff with Python" by Al Sweigart for the pointer.

这篇关于通过python读取Docx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆