python提取docx中带下划线的内容
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 11 11:29:35 2022
@author: koneko
"""
from docx import Document
doc = Document(r"test.docx")
runs = doc.paragraphs[0].runs
block_with_underline = []
for run in runs:
print(run.text)
print(run.underline)
if run.underline==True:
block_with_underline.append(run.text)
for block in block_with_underline:
print(block)