最新下载
热门教程
- 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)
相关文章
- jm天堂网页版官方登录入口-jm天堂网页版直接登录入口 12-14
- 蝉妈妈网页版直达入口-蝉妈妈app官方正版入口在哪 12-14
- 豆包AI智能在线网页解析神器-豆包AI智能在线会议纪要生成助手 12-14
- 小红书Web官网登录入口-小红书官方网页版一键登录 12-14
- 苍云阅读app如何快速找到目录-目录入口位置 12-14
- 苹果ID登录官网入口 - 苹果Apple ID账户登录页面一键直达 12-14