您好,欢迎访问一九零五行业门户网

python读取word中的文本内容

python可以利用python-docx模块处理word文档,处理方式是面向对象的。
安装 :在cmd命令行中输入 pip install python-docx  
最后提示successfully installed,表示成功地安装完成
代码:
# encoding=utf-8 import docx #获取文档对象 file=docx.document("e:\\pythoncode\\t11308010102mayuwen.docx") print("段落数:"+str(len(file.paragraphs)))#段落数 #输出每一段的内容 for para in file.paragraphs: print(para.text)
结果如图:
以上就是python读取word中的文本内容 的详细内容。
其它类似信息

推荐信息