Я пытался использовать модуль python-docx.До сих пор я был в состоянии извлечь отдельные абзацы, а также весь текст из файла слов.
pip install --pre python-docx #to install python-docx
from docx import Document
document = Document('file.docx')
document.paragraphs # to extract paragraphs
document.paragraphs[2].text # gives the text
for par in document.paragraphs: # to extract the whole text
print(par.text)
# I tried the below code to find some specific term
for i in range(0, 50, 1):
if (document.paragraphs[i].text == ('Some-word')):
print document.paragraph
Я ожидаю найти определенное слово в выделенномФорма в текстовом файле