Python DOCX文件操作:docx2txt

docx2txt

github链接
Ladies and gentlemen, please allow me to present, the fabulously handy, simple yet elegant, pure utility tool for extracting text from a docx file… the docx2txt for python.
将docx文件转换为txt格式的模块
能够直接读取docx文档并将其中的文本部分剥离出来的简单工具

安装

pip install docx2txt

运行

a. 使用命令行

# extract text
docx2txt file.docx
# extract text and images
docx2txt -i /tmp/img_dir file.docx

b. Python调用

import docx2txt

# extract text
text = docx2txt.process("file.docx")

# extract text and write images in /tmp/img_dir
text = docx2txt.process("file.docx", "/tmp/img_dir") 

如果需要将图片返回,可以在源码97-104行中添加相关功能
编码是utf-8

随笔

还有一个月就要远行,再拼一个10年。
离开安逸,离开软弱,这令我恐惧,但不会让我麻痹。
从现在就开始离开安逸,离开软弱吧,不在这么几天。
签证下来就辞职(・ω<)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值