colorand other styling information associated with it style in word is collection of these attributes run object is contiguous run of text with the same style new run object is needed whenever the text style changes reading word documents let' experiment with the docx module download demo docx from nostarch com/automatestuff and save the document to the working directory then enter the following into the interactive shellimport docx doc docx document('demo docx'len(doc paragraphs doc paragraphs[ text 'document titledoc paragraphs[ text ' plain paragraph with some bold and some italiclen(doc paragraphs[ runs doc paragraphs[ runs[ text ' plain paragraph with some doc paragraphs[ runs[ text 'bolddoc paragraphs[ runs[ text and some doc paragraphs[ runs[ text 'italicat we open docx file in pythoncall docx document()and pass the filename demo docx this will return document objectwhich has paragraphs attribute that is list of paragraph objects when we call len(on doc paragraphsit returns which tells us that there are seven paragraph objects in this document each of these paragraph objects has text attribute that contains string of the text in that paragraph (without the style informationherethe first text attribute contains 'documenttitleand the second contains ' plain paragraph with some bold and some italiceach paragraph object also has runs attribute that is list of run objects run objects also have text attributecontaining just the text in that particular run let' look at the text attributes in the second paragraph object' plain paragraph with some bold and some italiccalling len(on this paragraph object tells us that there are four run objects the first run object contains ' plain paragraph with some thenthe text changes to bold styleso 'boldstarts new run object the text returns to an unbolded style after thatwhich results in third run objectand some finallythe fourth and last run object contains 'italicin an italic style with python-docxyour python programs will now be able to read the text from docx file and use it just like any other string value working with pdf and word documents