首页 > 其他 > 详细

使用 docx 记录

时间:2021-03-01 16:14:54      阅读:19      评论:0      收藏:0      [点我收藏+]

 

 

 

 

1.使用 python-docx 模块提取导航标题

说明文档 https://python-docx.readthedocs.io/en/latest/index.html

from docx import Document

document = Document(123.docx)
paragraphs = document.paragraphs

document_1 = Document()
li = []
se = set()

for i in paragraphs:
  # #拿到段落格式样式
  # print(repr(i.style.name))
  # se.add(i.style.name)

  if i.style.name in {Heading 1,Heading 2,Heading 3,Heading4,Heading 5, Caption}:# ‘附录F表‘
      # li.append([i.style.name,i.text,i])
    
      p1 = document_1.add_paragraph()
      p1.style = document_1.styles[i.style.name]
      p1.add_run(text=i.text)

document_1.save(qwe.docx)

 

使用 docx 记录

原文:https://www.cnblogs.com/Bluemomo/p/14463190.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!