0
I am trying to verify a document (.DOCX)

And pick up the text that is with a certain style. Turns out the code I came up with in my attempts can only get the whole paragraph. I’d like to take part of the paragraph that has a different style.
import os
import re
from docx import Document
document = Document('C:/Pastas/Arquivo.docx')
for p in document.paragraphs:
    if p.style.name == 'Estilo_Procurado':
        print(p.text)
    else:
        print("Outro Estilo")
Using the .runs I was able to find the style in part of a paragraph, but to apply the if he can’t find the style and so I can’t get the text.
import os
import re
from docx import Document
document = Document('C:/Pastas/Arquivo.docx')
for p in document.paragraphs:
    for r in p.runs:
        if r.style.name == 'Estilo_Procurado':
            print(r.text)
        else:
            print("Outro estilo")
						

Without the input of your problem it becomes complicated to elaborate an effective answer. Provide the file
.docxin question.– Lacobus
I edited the question, you can understand the problem now?
– Rodolfo Rocha Dos Santos
You could provide a sample of that file ?
– Lacobus
I can not load the file here, but you can create any word file and fill with random text and change the Style of some part, as I did to test the codes.
– Rodolfo Rocha Dos Santos