Python Forum
How to add run in paragraph using python-docx? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to add run in paragraph using python-docx? (/thread-33636.html)



How to add run in paragraph using python-docx? - toothedsword - May-12-2021

I want to put runs in one paragraph to another using , so I write code like this: But it does not work. How should I change this code?

from docx import Document
import re
                                                                                                                                                 
master = Document("out.docx")
po = master.add_paragraph('It is: ')
doc = Document("in4.docx")
for p in doc.paragraphs:
    if re.search('yyy', p.text):
        for r in p.runs:
            master.paragraphs[-1].runs.append(r)
master.save('out1.doc1')    
Thanks!