最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Ubuntu下使用python读取doc和docx文档的内容方法
时间:2022-06-30 19:09:54 编辑:袖梨 来源:一聚教程网
读取docx文档
使用的包是python-docx
1. 安装python-docx包
sudo pip install python-docx
2. 使用python-docx包读取数据
#encoding:utf8
import docx
doc = docx.Document('test.docx')
docText = 'n'.join([paragraph.text for paragraph in doc.paragraphs])
#print(docText)
python-docx这个包是不能处理doc文档的,要读取doc文档内容的话需要使用antiword这个工具。
读取doc文档
1. 到下载antiword。
2. 下载完毕之后解压,在解压得到的文件夹中依次运行make和make install命令。
3. 使用antiword读取doc文档内容
#encoding:utf8 import subprocess word = 'test.doc' output = subprocess.check_output(['antiword',word]) print(output)
相关文章
- 小米路由器cr6608评测(小米路由器cr6608怎么样) 08-21
- 问真八字排盘免费版入口 08-21
- Linux如何清理Docker镜像 08-21
- 编程中的同步与异步:与现实世界的对比 08-21
- 红色沙漠机械大师如何打-红色沙漠机械大师简单打法介绍 08-21
- 掌握ai数据中台策略助力企业提升决策效率和工作流程 08-21