P002-将word文档内容复制到text文件中
convert_to_txt.py
import docx
doc = docx.Document('/work/sourcedir/output0951.docx')
text = ''
for paragraph in doc.paragraphs:
text += paragraph.text + '\n'
with open('/work/sourcedir/output0951.txt', 'w') as file:
file.write(text)
如果没有doc库则安装 pip install python-docx
日期:2024-02-28
通过知识/经验的分享,节省开发者的时间.