{"id":2140,"date":"2019-06-12T06:44:32","date_gmt":"2019-06-12T04:44:32","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=2140"},"modified":"2019-06-12T06:44:32","modified_gmt":"2019-06-12T04:44:32","slug":"read-text-in-a-word-document-with-python","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/read-text-in-a-word-document-with-python\/","title":{"rendered":"Read text in a Word document with Python"},"content":{"rendered":"<p>You can read text with this code in a Word document.<\/p>\n<pre class=\"lang:default decode:true \">from docx import Document\r\n\r\ndocument = Document(\"file.docx\")\r\n\r\nfor p in document.paragraphs:\r\n\tprint(p.text)<\/pre>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" title=\"Read text in Word document with Python\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/pj3PghOovEQ?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"You can read text with this code in a Word document.\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/read-text-in-a-word-document-with-python\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-2140","post","type-post","status-publish","format-standard","hentry","category-examples"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=2140"}],"version-history":[{"count":1,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2140\/revisions"}],"predecessor-version":[{"id":2141,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2140\/revisions\/2141"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=2140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=2140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=2140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}