python-读取word中的内容

doc = Document(r'D:\xxxx\xxxx\xxx.docx')

#读取word中所有内容

for p in doc.paragraphs

print(p,p.text)

#读取指定段落中的所有run(文字块)

for run in doc.paragraphs[1].runs:

print(run,run.text)

#读取word中所有表格内容

for 表格 in doc.tables:

print(表格)

for 行 in 表格.rows:

for 单元格 in 行.cells:

print(单元格.text)

相关推荐
Ιτ-ωoгκεг14 小时前
在 Java 中使用 Apache POI 为 Word 文档添加水印
java·word·apache·poi·水印
LiQiang3314 小时前
WPS Word中英文混杂空格和行间距不一致调整方案
word·wps
HACKNOE2 天前
python从入门到精通(二十六):python文件操作之Word全攻略(基于python-docx)
python·c#·word
inxunoffice2 天前
删除或替换 Word 中的首页、尾页以及其它指定范围的页
word
inxunoffice2 天前
批量在 Word 的指定位置插入页,如插入封面、末尾插入页面
word
勘察加熊人2 天前
python将pdf转换成word
python·pdf·word
LongtengGensSupreme3 天前
Net8 Spire最新版去水印,去页数限制,转word/pptx/ofd等
word
万物得其道者成3 天前
Vue 3 实现 HTML 内容预览功能:仿 Word 样式与内存安全实践
vue.js·html·word
懂点技术的abin3 天前
使用Word时无法粘贴,弹出错误提示:运行时错误‘53‘:文件未找到:MathPage.WLL
word
inxunoffice3 天前
批量将 Word 拆分成多个文件
word