这是一个示例代码,你可以根据你的需求进行修改:
import docx
def extract_sentences(doc_path, keywords, txt_path):# 打开文档
doc = docx.Document(doc_path)
# 创建空列表来存储句子
sentences = []
# 遍历文档中的每一个段落
for paragraph in doc.paragraphs:
# 遍历段落中的每一个句子
for sentence in paragraph.tex