{"id":332496,"date":"2022-04-27T15:00:37","date_gmt":"2022-04-27T15:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332496"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332496","title":{"rendered":"<span>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 docx c \u043f\u043e\u043c\u043e\u0449\u044c\u044e bayoo-docx<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d23\/4a1\/bcb\/d234a1bcb7f21540cc3e8892b030a935.png\" width=\"439\" height=\"414\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d23\/4a1\/bcb\/d234a1bcb7f21540cc3e8892b030a935.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 docx-\u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439? bayoo-docx (\u0444\u043e\u0440\u043a python-docx) \u0443\u043c\u0435\u0435\u0442 \u044d\u0442\u043e! \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0431\u043e\u043d\u0443\u0441\u0430 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. ?<\/p>\n<p>\u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 python-docx \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a word-\u0444\u0430\u0439\u043b\u0430\u043c \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0435\u0449\u0435 \u0432 2014 \u0433\u043e\u0434\u0443 <a href=\"https:\/\/github.com\/python-openxml\/python-docx\/issues\/93\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435<\/a> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 python-docx \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c, \u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/524288\/\" rel=\"noopener noreferrer nofollow\">xml<\/a>-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 2020 \u0433\u043e\u0434\u0443 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0444\u043e\u0440\u043a \u043e\u0442 python-docx \u2013 <a href=\"https:\/\/github.com\/BayooG\/bayoo-docx\" rel=\"noopener noreferrer nofollow\">bayoo-docx<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043b\u0435\u0433\u043a\u043e. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 <a href=\"https:\/\/github.com\/BayooG\/bayoo-docx\" rel=\"noopener noreferrer nofollow\">bayoo-docx<\/a>:<\/p>\n<pre><code>!pip install bayoo-docx<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/seatgeek\/thefuzz\" rel=\"noopener noreferrer nofollow\">thefuzz<\/a>, \u043e \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/491448\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043d \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u043a \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u0445\u043e\u0436\u0435\u0441\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D1%81%D1%81%D1%82%D0%BE%D1%8F%D0%BD%D0%B8%D0%B5_%D0%9B%D0%B5%D0%B2%D0%B5%D0%BD%D1%88%D1%82%D0%B5%D0%B9%D0%BD%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u041b\u0435\u0432\u0435\u043d\u0448\u0442\u0435\u0439\u043d\u0430.<\/a> \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code>!pip install thefuzz[speedup]<\/code><\/pre>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code>from docx import Document  from thefuzz import fuzz import ctypes<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/python\/cpython\/blob\/main\/Doc\/library\/ctypes.rst\" rel=\"noopener noreferrer nofollow\">ctypes<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f.<\/p>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f (\u043f\u043e \u0441\u0435\u0431\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u0442\u044f\u0436\u0435\u043b\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432). <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code># \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 doc = Document()<\/code><\/pre>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 Document \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0435\u0441\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u2013 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 Document \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0435\u0441\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u2013 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430: <\/p>\n<p> \u2022\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 paragraph \u2013 \u0430\u0431\u0437\u0430\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 run \u2013 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043a\u0443\u0440\u0441\u0438\u0432, \u0446\u0432\u0435\u0442 \u0448\u0440\u0438\u0444\u0442\u0430 \u0438 \u0442.\u043f.)<\/p>\n<p> \u2022\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 table \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 row \u2013 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 cell \u2013 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435<br \/>                \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 cell.paragraphs \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0430\u0431\u0437\u0430\u0446\u044b \u0432 \u044f\u0447\u0435\u0439\u043a\u0435<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 column \u2013 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b<br \/>                \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 cell \u2013 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435<\/p>\n<p> \u2022\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 InlineShape \u2013 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<pre><code>#\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0431\u0437\u0430\u0446\u044b doc.add_paragraph('\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430')  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u0440\u044b\u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b doc.add_page_break()  #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0431\u0437\u0430\u0446\u044b \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 doc.add_paragraph('\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0431\u0437\u0430\u0446, \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0431\u0437\u0430\u0446, \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0431\u0437\u0430\u0446, \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430')  # \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0435\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a items = (     (1, '\u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430', '\u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'),     (2, '\u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430', '\u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'),     (3, '\u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430', '\u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430'), )  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439  # \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a table = doc.add_table(1, len(items[0]))  # \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0442\u0438\u043b\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b table.style = 'Light Shading Accent 1'  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438 \u0438\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b head_cells = table.rows[0].cells  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a for i, item in enumerate(['\u043f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430', '\u0432\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430', '\u0442\u0440\u0435\u0442\u044c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430']):     p = head_cells[i].paragraphs[0]     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438     p.add_run(item).bold = True     # \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435     p.alignment = WD_ALIGN_PARAGRAPH.CENTER      # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 for row in items:     # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b     cells = table.add_row().cells     for i, item in enumerate(row):         # \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u044f\u0447\u0435\u0439\u043a\u0438         cells[i].text = str(item)          # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c        doc.save('test.docx')<\/code><\/pre>\n<p>\u0412\u0438\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p> \u2022\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/68b\/89c\/8cd\/68b89c8cda535904b0c03fd616e75399.png\" width=\"1377\" height=\"539\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68b\/89c\/8cd\/68b89c8cda535904b0c03fd616e75399.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u2022\u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/243\/264\/b33\/243264b33cf85200c367ad4556b9b983.png\" width=\"1349\" height=\"717\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/243\/264\/b33\/243264b33cf85200c367ad4556b9b983.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 document.elements (\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b paragraph (\u0430\u0431\u0437\u0430\u0446\u044b), \u0430 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b paragraph, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u044f\u0447\u0435\u0439\u043a\u0430\u0445.<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code># \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 elements for element in doc.elements:     print(element)  &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13580> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13550> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13BB0> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13790> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D138B0> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13400> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13AF0> &lt;docx.table.Table object at 0x0000026F87D13B50> &lt;docx.section.Section object at 0x0000026F87D13D30><\/code><\/pre>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0441 \u0430\u0431\u0437\u0430\u0446\u0430\u043c\u0438 \u043d\u0443\u0436\u0435\u043d \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a \u0430\u0431\u0437\u0430\u0446\u0443 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f\u043c\u0438 \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430. \u042f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u043d\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0430\u0431\u0437\u0430\u0446\u0435\u0432, \u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0430\u0431\u0437\u0430\u0446\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u044b (runs), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043b\u0435\u0438\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0431\u043e\u0440\u0430 \u0430\u0431\u0437\u0430\u0446\u0435\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>def filter_element(document):     \"\"\"     This function take all paragraphs in file.      :param document: object of document     :return: list of paragraphs in file.docx - document     \"\"\"     res = []     for element in document.elements:         if 'paragraph' in str(element):              res.append(element)         elif 'table' in str(element):             for row in element.rows:                 for cell in row.cells:                     res.append(cell.paragraphs)     return res <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code>def get_display_name():     \"\"\"     This function return full name of user.     out:         string: full name of user     \"\"\"     get_user_name_ex = ctypes.windll.secur32.GetUserNameExW     name_display = 3     size = ctypes.pointer(ctypes.c_ulong(0))     get_user_name_ex(name_display, None, size)     name_buffer = ctypes.create_unicode_buffer(size.contents.value)     get_user_name_ex(name_display, name_buffer, size)     return name_buffer.value<\/code><\/pre>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f:<\/p>\n<pre><code>def make_comment(text:str, paragraphs:list, user:str):     \"\"\"     This function adds comments in docx files.     :param text: the line we are looking for     :param paragraphs: list of paragraphs to search for a string     :param user: full name of user     \"\"\"     for paragraph in paragraphs:         if type(paragraph) == list:              text_in_table = [p.text for p in paragraph]             text_in_table = ''.join(text_in_table)              if len(text_in_table) >= len(text)-5:                  res = fuzz.partial_ratio(text.lower(), text_in_table.lower())                 if res >= 97:                      p = paragraph[-1]                     run = p.add_run()                     run.add_comment('\u0421\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043a\u0430\u043b\u0438', author=user)          else:              if len(paragraph.text) >= len(text):                 res = fuzz.partial_ratio(text.lower(), paragraph.text.lower())                 if res >= 97:                     paragraph.add_comment('\u0421\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043a\u0430\u043b\u0438', author=user)<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e document:<\/p>\n<pre><code>document = Document('test.docx')<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<pre><code>text = '\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b'<\/code><\/pre>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u0435\u0432 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<pre><code>paragraphs = filter_element(document)<\/code><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e name_of_user:<\/p>\n<pre><code>name_of_user = get_display_name()<\/code><\/pre>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b (\u0438\u0441\u043a\u043e\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u0435\u0432, \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f):<\/p>\n<p><code>make_comment(text, paragraphs, name_of_user)<\/code><\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b:<\/p>\n<p><code>document.save('test \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c.docx')<\/code><\/p>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043a\u043e\u043f\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/44b\/9a6\/6da\/44b9a66dac9fa25f3cf5604eb856cc9e.png\" width=\"1654\" height=\"522\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/44b\/9a6\/6da\/44b9a66dac9fa25f3cf5604eb856cc9e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<pre><code>#\u043e\u0431\u044c\u0435\u043a\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 document = Document('test.docx') # \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0449\u0435\u043c text = \"\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430\" # \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u0435\u0432 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 paragraphs = filter_element(document) # \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f name_of_user = get_display_name() # \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 make_comment(text, paragraphs, name_of_user) # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b .docx document.save('test \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c.docx')<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/920\/21c\/6a3\/92021c6a39537004e902547ceba50df2.png\" width=\"1632\" height=\"338\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/920\/21c\/6a3\/92021c6a39537004e902547ceba50df2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044e.<\/p>\n<h4>\u041e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441<\/h4>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043d\u0430\u0448\u043b\u0438, \u2639 \u0442\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u00ab\u043a\u043e\u0441\u0442\u044b\u043b\u0438\u00bb ?.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bac\/12f\/bc3\/bac12fbc31b015cdb1c021e46ed2b058.png\" width=\"324\" height=\"346\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bac\/12f\/bc3\/bac12fbc31b015cdb1c021e46ed2b058.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0437\u0440\u044b\u0432\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0432\u0438\u0434\u043e\u0432: <\/p>\n<p>1)\u00a0 hard breaks \u2013 \u0440\u0430\u0437\u0440\u044b\u0432\u044b, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ctrl + Enter. <\/p>\n<p>2)\u00a0 soft breaks \u2013 \u0440\u0430\u0437\u0440\u044b\u0432\u044b, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u0430\u0432\u0442\u043e\u0440 \u043f\u0435\u0447\u0430\u0442\u0430\u043b \u0442\u0435\u043a\u0441\u0442, \u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. <\/p>\n<p>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0440\u0430\u0437\u0440\u044b\u0432\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0432 xml-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 run (run._element.xml), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 paragraph.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code>def number_page(text:str, paragraphs:list):     \"\"\"     This funcion find number page.      :param text: string what we find     :param paragraphs: list of paragraphs     :return: pages     \"\"\"     pages = []     number_page = 1     for paragraph in paragraphs:         if type(paragraph) == list:              text_in_table = [p.text for p in paragraph]             text_in_table = ''.join(text_in_table)             for p in paragraph:                 for run in p.runs:                      if 'lastRenderedPageBreak' in run._element.xml:                         number_page += 1                      elif 'w:br' in run._element.xml and 'type=\"page\"' in run._element.xml:                         number_page += 1             if len(text_in_table) >= len(text)-10:                 res = fuzz.partial_ratio(text.lower(), text_in_table.lower())                 if res >= 97:                      pages.append(number_page)         else:              for run in paragraph.runs:                 if 'lastRenderedPageBreak' in run._element.xml:                     number_page += 1                 elif 'w:br' in run._element.xml and 'type=\"page\"' in run._element.xml:                     number_page += 1             if len(paragraph.text) >= len(text):                 res = fuzz.partial_ratio(text.lower(), paragraph.text.lower())                 if res >= 97:                     pages.append(number_page)     return ', '.join(map(str, pages)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0437\u0434\u0435\u0441\u044c XML-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 run \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0435\u0433\u043e\u0432, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0440\u0430\u0437\u0440\u044b\u0432\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code>if 'lastRenderedPageBreak' in run._element.xml:     number_page += 1  elif 'w:br' in run._element.xml and 'type=\"page\"' in run._element.xml:     number_page += 1<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 document document = Document('test.docx') # \u0441\u043d\u043e\u0432\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 paragraphs = filter_element(document) # \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u043e\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 text = \"\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430\"<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e number_page \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043a\u0430\u043b\u0438, \u0432\u0442\u043e\u0440\u044b\u043c \u2013 \u0441\u043f\u0438\u0441\u043e\u043a paragraphs.<\/p>\n<pre><code>print(number_page(text, paragraphs))<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430.<\/p>\n<p>Jupyter notebook \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 \u043a \u043a\u043e\u0434\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e <a href=\"https:\/\/github.com\/zippo761\/Bayoo-docx-example\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>\u0424\u043e\u0440\u043a bayoo-docx \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 python-docx, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043f\u043e\u043a\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0442.\u043a. \u0440\u0430\u0437\u0440\u044b\u0432\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0432\u0438\u0436\u043a\u043e\u043c. \u0412\u0441\u0435 \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u043e\u043f\u0430\u0432\u0448\u0438\u0441\u044c \u0432 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 docx, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0432\u0440\u0443\u0447\u043d\u0443\u044e. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/663028\/\"> https:\/\/habr.com\/ru\/post\/663028\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 docx-\u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439? bayoo-docx (\u0444\u043e\u0440\u043a python-docx) \u0443\u043c\u0435\u0435\u0442 \u044d\u0442\u043e! \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0431\u043e\u043d\u0443\u0441\u0430 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. ?<\/p>\n<p>\u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 python-docx \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a word-\u0444\u0430\u0439\u043b\u0430\u043c \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0435\u0449\u0435 \u0432 2014 \u0433\u043e\u0434\u0443 <a href=\"https:\/\/github.com\/python-openxml\/python-docx\/issues\/93\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435<\/a> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 python-docx \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c, \u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/524288\/\" rel=\"noopener noreferrer nofollow\">xml<\/a>-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 2020 \u0433\u043e\u0434\u0443 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0444\u043e\u0440\u043a \u043e\u0442 python-docx \u2013 <a href=\"https:\/\/github.com\/BayooG\/bayoo-docx\" rel=\"noopener noreferrer nofollow\">bayoo-docx<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043b\u0435\u0433\u043a\u043e. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 <a href=\"https:\/\/github.com\/BayooG\/bayoo-docx\" rel=\"noopener noreferrer nofollow\">bayoo-docx<\/a>:<\/p>\n<pre><code>!pip install bayoo-docx<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/seatgeek\/thefuzz\" rel=\"noopener noreferrer nofollow\">thefuzz<\/a>, \u043e \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/491448\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043d \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u043a \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u0445\u043e\u0436\u0435\u0441\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D1%81%D1%81%D1%82%D0%BE%D1%8F%D0%BD%D0%B8%D0%B5_%D0%9B%D0%B5%D0%B2%D0%B5%D0%BD%D1%88%D1%82%D0%B5%D0%B9%D0%BD%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u041b\u0435\u0432\u0435\u043d\u0448\u0442\u0435\u0439\u043d\u0430.<\/a> \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code>!pip install thefuzz[speedup]<\/code><\/pre>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code>from docx import Document  from thefuzz import fuzz import ctypes<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/python\/cpython\/blob\/main\/Doc\/library\/ctypes.rst\" rel=\"noopener noreferrer nofollow\">ctypes<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f.<\/p>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f (\u043f\u043e \u0441\u0435\u0431\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u0442\u044f\u0436\u0435\u043b\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432). <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code># \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 doc = Document()<\/code><\/pre>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 Document \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0435\u0441\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u2013 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 Document \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0435\u0441\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u2013 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430: <\/p>\n<p> \u2022\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 paragraph \u2013 \u0430\u0431\u0437\u0430\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 run \u2013 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043a\u0443\u0440\u0441\u0438\u0432, \u0446\u0432\u0435\u0442 \u0448\u0440\u0438\u0444\u0442\u0430 \u0438 \u0442.\u043f.)<\/p>\n<p> \u2022\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 table \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 row \u2013 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 cell \u2013 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435<br \/>                \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 cell.paragraphs \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0430\u0431\u0437\u0430\u0446\u044b \u0432 \u044f\u0447\u0435\u0439\u043a\u0435<br \/>           &#8212; \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 column \u2013 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b<br \/>                \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 cell \u2013 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435<\/p>\n<p> \u2022\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 InlineShape \u2013 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<pre><code>#\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0431\u0437\u0430\u0446\u044b doc.add_paragraph('\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430')  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u0440\u044b\u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b doc.add_page_break()  #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0431\u0437\u0430\u0446\u044b \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 doc.add_paragraph('\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0431\u0437\u0430\u0446, \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0431\u0437\u0430\u0446, \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430') doc.add_paragraph('\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0431\u0437\u0430\u0446, \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430')  # \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0435\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a items = (     (1, '\u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430', '\u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'),     (2, '\u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430', '\u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'),     (3, '\u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430', '\u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430'), )  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439  # \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a table = doc.add_table(1, len(items[0]))  # \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0442\u0438\u043b\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b table.style = 'Light Shading Accent 1'  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438 \u0438\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b head_cells = table.rows[0].cells  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a for i, item in enumerate(['\u043f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430', '\u0432\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430', '\u0442\u0440\u0435\u0442\u044c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430']):     p = head_cells[i].paragraphs[0]     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438     p.add_run(item).bold = True     # \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435     p.alignment = WD_ALIGN_PARAGRAPH.CENTER      # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 for row in items:     # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b     cells = table.add_row().cells     for i, item in enumerate(row):         # \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u044f\u0447\u0435\u0439\u043a\u0438         cells[i].text = str(item)          # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c        doc.save('test.docx')<\/code><\/pre>\n<p>\u0412\u0438\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p> \u2022\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u2022\u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 document.elements (\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b paragraph (\u0430\u0431\u0437\u0430\u0446\u044b), \u0430 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b paragraph, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u044f\u0447\u0435\u0439\u043a\u0430\u0445.<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code># \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 elements for element in doc.elements:     print(element)  &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13580> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13550> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13BB0> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13790> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D138B0> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13400> &lt;docx.text.paragraph.Paragraph object at 0x0000026F87D13AF0> &lt;docx.table.Table object at 0x0000026F87D13B50> &lt;docx.section.Section object at 0x0000026F87D13D30><\/code><\/pre>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0441 \u0430\u0431\u0437\u0430\u0446\u0430\u043c\u0438 \u043d\u0443\u0436\u0435\u043d \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a \u0430\u0431\u0437\u0430\u0446\u0443 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f\u043c\u0438 \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430. \u042f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u043d\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0430\u0431\u0437\u0430\u0446\u0435\u0432, \u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0430\u0431\u0437\u0430\u0446\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u044b (runs), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043b\u0435\u0438\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0431\u043e\u0440\u0430 \u0430\u0431\u0437\u0430\u0446\u0435\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>def filter_element(document):     \"\"\"     This function take all paragraphs in file.      :param document: object of document     :return: list of paragraphs in file.docx - document     \"\"\"     res = []     for element in document.elements:         if 'paragraph' in str(element):              res.append(element)         elif 'table' in str(element):             for row in element.rows:                 for cell in row.cells:                     res.append(cell.paragraphs)     return res <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code>def get_display_name():     \"\"\"     This function return full name of user.     out:         string: full name of user     \"\"\"     get_user_name_ex = ctypes.windll.secur32.GetUserNameExW     name_display = 3     size = ctypes.pointer(ctypes.c_ulong(0))     get_user_name_ex(name_display, None, size)     name_buffer = ctypes.create_unicode_buffer(size.contents.value)     get_user_name_ex(name_display, name_buffer, size)     return name_buffer.value<\/code><\/pre>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f:<\/p>\n<pre><code>def make_comment(text:str, paragraphs:list, user:str):     \"\"\"     This function adds comments in docx files.     :param text: the line we are looking for     :param paragraphs: list of paragraphs to search for a string     :param user: full name of user     \"\"\"     for paragraph in paragraphs:         if type(paragraph) == list:              text_in_table = [p.text for p in paragraph]             text_in_table = ''.join(text_in_table)              if len(text_in_table) >= len(text)-5:                  res = fuzz.partial_ratio(text.lower(), text_in_table.lower())                 if res >= 97:                      p = paragraph[-1]                     run = p.add_run()                     run.add_comment('\u0421\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043a\u0430\u043b\u0438', author=user)          else:              if len(paragraph.text) >= len(text):                 res = fuzz.partial_ratio(text.lower(), paragraph.text.lower())                 if res >= 97:                     paragraph.add_comment('\u0421\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043a\u0430\u043b\u0438', author=user)<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e document:<\/p>\n<pre><code>document = Document('test.docx')<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<pre><code>text = '\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0431\u0437\u0430\u0446, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b'<\/code><\/pre>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u0435\u0432 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<pre><code>paragraphs = filter_element(document)<\/code><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e name_of_user:<\/p>\n<pre><code>name_of_user = get_display_name()<\/code><\/pre>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b (\u0438\u0441\u043a\u043e\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u0435\u0432, \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f):<\/p>\n<p><code>make_comment(text, paragraphs, name_of_user)<\/code><\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b:<\/p>\n<p><code>document.save('test \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c.docx')<\/code><\/p>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043a\u043e\u043f\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<pre><code>#\u043e\u0431\u044c\u0435\u043a\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 document = Document('test.docx') # \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0449\u0435\u043c text = \"\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430\" # \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0431\u0437\u0430\u0446\u0435\u0432 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 paragraphs = filter_element(document) # \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f name_of_user = get_display_name() # \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 make_comment(text, paragraphs, name_of_user) # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b .docx document.save('test \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c.docx')<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044e.<\/p>\n<h4>\u041e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441<\/h4>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043d\u0430\u0448\u043b\u0438, \u2639 \u0442\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u00ab\u043a\u043e\u0441\u0442\u044b\u043b\u0438\u00bb ?.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0437\u0440\u044b\u0432\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0432\u0438\u0434\u043e\u0432: <\/p>\n<p>1)\u00a0 hard breaks \u2013 \u0440\u0430\u0437\u0440\u044b\u0432\u044b, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ctrl + Enter. <\/p>\n<p>2)\u00a0 soft breaks \u2013 \u0440\u0430\u0437\u0440\u044b\u0432\u044b, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u0430\u0432\u0442\u043e\u0440 \u043f\u0435\u0447\u0430\u0442\u0430\u043b \u0442\u0435\u043a\u0441\u0442, \u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. <\/p>\n<p>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0440\u0430\u0437\u0440\u044b\u0432\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0432 xml-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 run (run._element.xml), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 paragraph.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code>def number_page(text:str, paragraphs:list):     \"\"\"     This funcion find number page.      :param text: string what we find     :param paragraphs: list of paragraphs     :return: pages     \"\"\"     pages = []     number_page = 1     for paragraph in paragraphs:         if type(paragraph) == list:              text_in_table = [p.text for p in paragraph]             text_in_table = ''.join(text_in_table)             for p in paragraph:                 for run in p.runs:                      if 'lastRenderedPageBreak' in run._element.xml:                         number_page += 1                      elif 'w:br' in run._element.xml and 'type=\"page\"' in run._element.xml:                         number_page += 1             if len(text_in_table) >= len(text)-10:                 res = fuzz.partial_ratio(text.lower(), text_in_table.lower())                 if res >= 97:                      pages.append(number_page)         else:              for run in paragraph.runs:                 if 'lastRenderedPageBreak' in run._element.xml:                     number_page += 1                 elif 'w:br' in run._element.xml and 'type=\"page\"' in run._element.xml:                     number_page += 1             if len(paragraph.text) >= len(text):                 res = fuzz.partial_ratio(text.lower(), paragraph.text.lower())                 if res >= 97:                     pages.append(number_page)     return ',<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-332496","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332496"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332496\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}