Python DOCX檔案操作:docx2txt
阿新 • • 發佈:2019-02-13
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年。
離開安逸,離開軟弱,這令我恐懼,但不會讓我麻痺。
從現在就開始離開安逸,離開軟弱吧,不在這麼幾天。
簽證下來就辭職(・ω<)