读取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)
ubuntu系统如何查看版本 ubuntu系统查看版本方法
ubuntu21.04如何创建桌面快捷图标 ubuntu21.04创建桌面快捷图标方法
ubuntu20.04如何设置字体大小 ubuntu20.04设置字体大小方法
Ubuntu 18.04 LTS中配置IP地址的完整教程
Ubuntu下如何创建XFS文件系统的LVM详解
Ubuntu 16.04设置PostgreSQL开机启动的方法