Uploaded by Surender Rana

Python coding to extract bold and italics from docx

advertisement
from docx import *
document =
Document(C:\Users\admin\Desktop\9780134730714_Test\9780134730714_Web.docx)
bolds=[]
italics=[]
for para in document.paragraphs:
for run in para.runs:
if run.italic :
italics.append(run.text)
if run.bold :
bolds.append(run.text)
boltalic_Dict={'bold_phrases':bolds,
'italic_phrases':italics}
Download