{"id":222666,"date":"2024-05-11T19:03:15","date_gmt":"2024-05-11T11:03:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/222666.html"},"modified":"2024-05-11T19:03:19","modified_gmt":"2024-05-11T11:03:19","slug":"python%e5%9c%a8macos%e4%b8%8b%e5%a6%82%e4%bd%95%e8%af%bb%e5%8f%96word%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/222666.html","title":{"rendered":"python\u5728MacOS\u4e0b\u5982\u4f55\u8bfb\u53d6word\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25142406\/feb4ed76-1db5-455e-8cfe-d7cc77d44790.webp\" alt=\"python\u5728MacOS\u4e0b\u5982\u4f55\u8bfb\u53d6word\u6587\u4ef6\" \/><\/p>\n<p><p><strong>Python\u5728MacOS\u4e0b\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u5e93\u6765\u8bfb\u53d6Word\u6587\u4ef6\uff0c\u4f8b\u5982\u4f7f\u7528<code>python-docx<\/code>\u3001<code>pywin32<\/code>\uff08\u4ec5\u9650\u4e8eWindows\uff09\u6216\u5229\u7528<code>macOS<\/code>\u7684<code>Automator<\/code>\u670d\u52a1\u3002<\/strong> \u6700\u76f4\u63a5\u548c\u901a\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>python-docx<\/code>\u5e93\uff0c\u8fd9\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684Python\u5e93\uff0c\u80fd\u591f\u8bfb\u53d6\u548c\u4fee\u6539<code>.docx<\/code>\u6587\u4ef6\uff0c\u800c\u4e0d\u4f9d\u8d56\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u3002\u901a\u8fc7<code>python-docx<\/code>\u5e93\u53ef\u4ee5\u63d0\u53d6\u6587\u6863\u5185\u5bb9\u3001\u64cd\u4f5c\u6bb5\u843d\u3001\u8fd0\u884c\u4ee5\u53ca\u8868\u683c\u7b49\u3002\u63a5\u4e0b\u6765\uff0c\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528<code>python-docx<\/code>\u6765\u8bfb\u53d6Word\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5b89\u88c5python-docx\u5e93<\/h2>\n<\/p>\n<p><p>\u5728MacOS\u4e0b\uff0c\u8981\u4f7f\u7528python-docx\u5e93\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u8be5\u5e93\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install python-docx<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u786e\u4fddPython\u7684pip\u547d\u4ee4\u5df2\u7ecf\u5b89\u88c5\uff0c\u8fd9\u901a\u5e38\u662f\u4f34\u968fPython\u4e00\u8d77\u5b89\u88c5\u7684\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165\u5e76\u4f7f\u7528\u8fd9\u4e2a\u5e93\u4e86\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u8bfb\u53d6Word\u6587\u6863<\/h2>\n<\/p>\n<p><p><strong>\u4f7f\u7528<code>python-docx<\/code>\u5e93\u8bfb\u53d6Word\u6587\u6863\u975e\u5e38\u7b80\u6d01\u3002<\/strong> \u53ea\u9700\u51e0\u884c\u4ee3\u7801\uff0c\u5c31\u80fd\u6253\u5f00\u4e00\u4e2a\u6587\u6863\u5e76\u8bfb\u53d6\u5176\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from docx import Document<\/p>\n<h2><strong>\u8bfb\u53d6\u6587\u6863<\/strong><\/h2>\n<p>document = Document(&#039;example.docx&#039;)<\/p>\n<h2><strong>\u8f93\u51fa\u6bcf\u4e2a\u6bb5\u843d\u7684\u6587\u672c<\/strong><\/h2>\n<p>for paragraph in document.paragraphs:<\/p>\n<p>    print(paragraph.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u91cc\uff0c<code>Document<\/code>\u5bf9\u8c61\u8868\u793a\u6574\u4e2a\u6587\u6863\uff0c\u901a\u8fc7\u904d\u5386\u8fd9\u4e2a\u5bf9\u8c61\u7684<code>paragraphs<\/code>\u5c5e\u6027\uff0c\u53ef\u4ee5\u83b7\u5f97\u6587\u6863\u4e2d\u7684\u6bcf\u4e00\u4e2a\u6bb5\u843d\uff0c\u5e76\u6253\u5370\u51fa\u5b83\u4eec\u7684\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u63d0\u53d6\u6587\u6863\u7ed3\u6784<\/h2>\n<\/p>\n<p><p><strong>\u5bf9\u4e8e\u7ed3\u6784\u5316\u7684\u6587\u6863\uff0c\u9664\u4e86\u8bfb\u53d6\u7eaf\u6587\u672c\u5916\uff0c\u901a\u5e38\u8fd8\u9700\u8981\u4e86\u89e3\u5404\u4e2a\u90e8\u5206\u7684\u683c\u5f0f\u548c\u7ed3\u6784\u3002<\/strong> <code>python-docx<\/code>\u5141\u8bb8\u4f60\u8bfb\u53d6\u5404\u79cd\u6587\u6863\u5143\u7d20\uff0c\u6bd4\u5982\u6807\u9898\u3001\u8868\u683c\u3001\u56fe\u7247\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u63d0\u53d6\u6807\u9898<\/h3>\n<\/p>\n<p><p>Word\u6587\u6863\u4e2d\u7684\u6807\u9898\u901a\u5e38\u4f7f\u7528\u4e0d\u540c\u7ea7\u522b\u7684\u6837\u5f0f\u6765\u533a\u5206\u3002\u4f7f\u7528<code>python-docx<\/code>\u53ef\u4ee5\u63d0\u53d6\u8fd9\u4e9b\u6807\u9898\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from docx import Document<\/p>\n<p>document = Document(&#039;example.docx&#039;)<\/p>\n<p>for paragraph in document.paragraphs:<\/p>\n<p>    if paragraph.style.name.startswith(&#039;Heading&#039;):<\/p>\n<p>        print(paragraph.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u904d\u5386\u6587\u6863\u4e2d\u7684\u6240\u6709\u6bb5\u843d\uff0c\u5e76\u68c0\u67e5\u5b83\u4eec\u7684\u6837\u5f0f\u540d\u79f0\u662f\u5426\u4ee5&quot;Heading&quot;\u5f00\u59cb\uff0c\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u627e\u5230\u6587\u6863\u4e2d\u6240\u6709\u7ea7\u522b\u7684\u6807\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u63d0\u53d6\u8868\u683c<\/h3>\n<\/p>\n<p><p>\u63d0\u53d6Word\u6587\u6863\u4e2d\u7684\u8868\u683c\u5185\u5bb9\u4e5f\u662f<code>python-docx<\/code>\u7684\u5e38\u89c1\u7528\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from docx import Document<\/p>\n<p>document = Document(&#039;example.docx&#039;)<\/p>\n<p>for table in document.tables:<\/p>\n<p>    for row in table.rows:<\/p>\n<p>        for cell in row.cells:<\/p>\n<p>            print(cell.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u904d\u5386\u6587\u6863\u4e2d\u7684\u8868\u683c\u3001\u884c\u548c\u5355\u5143\u683c\uff0c\u8f93\u51fa\u5404\u4e2a\u5355\u5143\u683c\u4e2d\u7684\u6587\u672c\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u5904\u7406\u590d\u6742\u683c\u5f0f<\/h2>\n<\/p>\n<p><p><strong>\u5728Word\u6587\u6863\u4e2d\uff0c\u590d\u6742\u7684\u683c\u5f0f\u53ef\u80fd\u5305\u62ec\u56fe\u7247\u3001\u9875\u7709\u3001\u9875\u811a\u3001\u811a\u6ce8\u3001\u6587\u672c\u6846\u7b49\u5143\u7d20\u3002<\/strong> \u4f7f\u7528<code>python-docx<\/code>\u53ef\u4ee5\u4ee5\u4e0d\u540c\u65b9\u5f0f\u5904\u7406\u8fd9\u4e9b\u590d\u6742\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u5904\u7406\u56fe\u7247<\/h3>\n<\/p>\n<p><p>\u867d\u7136<code>python-docx<\/code>\u65e0\u6cd5\u76f4\u63a5\u63d0\u53d6\u5185\u5d4c\u7684\u56fe\u7247\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u6587\u6863\u4e2d\u6240\u6709\u7684\u6bb5\u843d\u548c\u8fd0\u884c\u6765\u67e5\u627e\u56fe\u7247\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from docx import Document<\/p>\n<p>document = Document(&#039;example.docx&#039;)<\/p>\n<p>for paragraph in document.paragraphs:<\/p>\n<p>    for run in paragraph.runs:<\/p>\n<p>        for inline in run.inline_shapes:<\/p>\n<p>            if inline.type == 3: # \u56fe\u7247\u7c7b\u578b<\/p>\n<p>                print(&#039;\u627e\u5230\u4e00\u5e45\u56fe\u7247&#039;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5904\u7406\u9875\u7709\u548c\u9875\u811a<\/h3>\n<\/p>\n<p><p>\u8981\u8bbf\u95ee\u9875\u7709\u548c\u9875\u811a\u4e2d\u7684\u5185\u5bb9\uff0c\u9700\u8981\u904d\u5386\u6587\u6863\u7684<code>sections<\/code>\uff0c\u7136\u540e\u63d0\u53d6\u6bcf\u4e2a\u90e8\u5206\u7684\u9875\u7709\u548c\u9875\u811a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from docx import Document<\/p>\n<p>document = Document(&#039;example.docx&#039;)<\/p>\n<p>for section in document.sections:<\/p>\n<p>    header = section.header<\/p>\n<p>    footer = section.footer<\/p>\n<p>    for paragraph in header.paragraphs:<\/p>\n<p>        print(paragraph.text)<\/p>\n<p>    for paragraph in footer.paragraphs:<\/p>\n<p>        print(paragraph.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e94\u3001\u9ad8\u7ea7\u5e94\u7528<\/h2>\n<\/p>\n<p><p>Python\u5e76\u4e0d\u9650\u4e8e\u4ec5\u8bfb\u53d6Word\u6587\u4ef6\u5185\u5bb9\u3002\u7ed3\u5408\u5176\u4ed6\u5e93\u548c\u6280\u672f\uff0c\u53ef\u4ee5\u5b9e\u73b0\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u4f7f\u7528\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u5e93\u6765\u5206\u6790\u6587\u672c\u3001\u5229\u7528<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\u6765\u505a\u60c5\u611f\u5206\u6790\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u7ed3\u5408<code>python-docx<\/code>\u548c\u5176\u4ed6\u6570\u636e\u5904\u7406\u5e93\uff08\u5982<code>pandas<\/code>\uff09\uff0c\u53ef\u4ee5\u521b\u5efa\u51fa\u529f\u80fd\u5f3a\u5927\u7684\u81ea\u52a8\u5316\u811a\u672c\uff0c\u5b83\u4eec\u53ef\u4ee5\u5206\u6790Word\u6587\u6863\u4e2d\u7684\u6570\u636e\u3001\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\uff0c\u751a\u81f3\u6839\u636e\u6570\u636e\u751f\u6210\u65b0\u7684\u62a5\u544a\u6587\u6863\u3002<\/p>\n<\/p>\n<p><p><strong>Python\u5728MacOS\u4e0b\u8bfb\u53d6Word\u6587\u4ef6\u7684\u529f\u80fd\u662f\u5f3a\u5927\u548c\u7075\u6d3b\u7684\u3002<\/strong> \u65e0\u8bba\u662f\u7b80\u5355\u5730\u63d0\u53d6\u6587\u672c\u3001\u83b7\u53d6\u6587\u6863\u7ed3\u6784\uff0c\u8fd8\u662f\u8fdb\u884c\u590d\u6742\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\uff0cPython\u90fd\u80fd\u901a\u8fc7\u76f8\u5e94\u7684\u5e93\u548c\u5de5\u5177\u6ee1\u8db3\u9700\u6c42\u3002\u5bf9\u4e8e\u64c5\u957f\u7f16\u7a0b\u548c\u9700\u8981\u5904\u7406\u5927\u91cf\u6587\u6863\u7684\u4eba\u6765\u8bf4\uff0cPython\u63d0\u4f9b\u4e86\u4e00\u79cd\u9ad8\u6548\u7684\u81ea\u52a8\u5316\u65b9\u6848\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>Q: \u5982\u4f55\u5728MacOS\u4e2d\u4f7f\u7528Python\u8bfb\u53d6Word\u6587\u4ef6\uff1f<\/strong><\/p>\n<p>A: \u5728MacOS\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684\u6587\u6863\u5904\u7406\u5e93\uff08\u5982python-docx\u5e93\uff09\u6765\u8bfb\u53d6Word\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5python-docx\u5e93<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>pip install python-docx<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u8be5\u5e93\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5bfc\u5165\u6240\u9700\u7684\u5e93<\/strong>\uff1a\u5728Python\u811a\u672c\u6587\u4ef6\u4e2d\uff0c\u9996\u5148\u9700\u8981\u5bfc\u5165python-docx\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528<code>import docx<\/code>\u8bed\u53e5\u6765\u5b9e\u73b0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5f00Word\u6587\u6863<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528<code>docx.Document()<\/code>\u51fd\u6570\u6253\u5f00Word\u6587\u6863\u3002\u4f8b\u5982\uff0c<code>doc = docx.Document(&#039;filename.docx&#039;)<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u8bfb\u53d6\u6bb5\u843d<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528<code>doc.paragraphs<\/code>\u5c5e\u6027\u6765\u83b7\u53d6Word\u6587\u6863\u4e2d\u7684\u6240\u6709\u6bb5\u843d\u3002\u904d\u5386\u8fd9\u4e9b\u6bb5\u843d\uff0c\u53ef\u4ee5\u83b7\u53d6\u6bcf\u4e2a\u6bb5\u843d\u7684\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u8bfb\u53d6\u8868\u683c<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528<code>doc.tables<\/code>\u5c5e\u6027\u6765\u83b7\u53d6Word\u6587\u6863\u4e2d\u7684\u6240\u6709\u8868\u683c\u3002\u904d\u5386\u8fd9\u4e9b\u8868\u683c\uff0c\u53ef\u4ee5\u83b7\u53d6\u6bcf\u4e2a\u8868\u683c\u7684\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5173\u95ed\u6587\u6863<\/strong>\uff1a\u5728\u8bfb\u53d6\u5b8c\u6210\u540e\uff0c\u4f7f\u7528<code>doc.close()<\/code>\u65b9\u6cd5\u6765\u5173\u95edWord\u6587\u6863\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u8fd9\u4e9b\u6b65\u9aa4\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728MacOS\u4e2d\u4f7f\u7528Python\u8bfb\u53d6Word\u6587\u4ef6\u3002\u795d\u60a8\u4f7f\u7528\u6109\u5feb\uff01<\/p>\n<p><strong>Q: \u5982\u4f55\u5728MacOS\u4f7f\u7528Python\u5904\u7406Word\u6587\u6863\u5185\u5bb9\uff1f<\/strong><\/p>\n<p>A: \u5728MacOS\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u6765\u5904\u7406Word\u6587\u6863\u7684\u5185\u5bb9\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u7528\u4e8e\u5904\u7406Word\u6587\u6863\u7684Python\u5e93\u548c\u65b9\u6cd5\u7684\u793a\u4f8b\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528python-docx\u5e93<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528python-docx\u5e93\u6765\u8bfb\u53d6\u3001\u4fee\u6539\u548c\u521b\u5efaWord\u6587\u6863\u3002\u8be5\u5e93\u63d0\u4f9b\u4e86\u8bb8\u591a\u65b9\u6cd5\u548c\u5c5e\u6027\u6765\u64cd\u4f5c\u6587\u6863\u7684\u4e0d\u540c\u90e8\u5206\uff0c\u5982\u6bb5\u843d\u3001\u6587\u672c\u3001\u8868\u683c\u3001\u6837\u5f0f\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528python-pptx\u5e93<\/strong>\uff1apython-pptx\u5e93\u4e0d\u4ec5\u9002\u7528\u4e8e\u5904\u7406PPT\u6587\u4ef6\uff0c\u8fd8\u53ef\u4ee5\u5904\u7406Word\u6587\u6863\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u8bfb\u53d6\u548c\u4fee\u6539Word\u6587\u6863\u7684\u5185\u5bb9\uff0c\u5305\u62ec\u6bb5\u843d\u3001\u56fe\u50cf\u3001\u6837\u5f0f\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528python-utils\u5e93<\/strong>\uff1apython-utils\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5b9e\u7528\u5de5\u5177\u548c\u51fd\u6570\uff0c\u53ef\u7528\u4e8e\u5904\u7406Word\u6587\u6863\u7684\u5185\u5bb9\u3002\u5b83\u5177\u6709\u5904\u7406\u6587\u672c\u3001\u6837\u5f0f\u3001\u8868\u683c\u7b49\u7684\u529f\u80fd\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u65e0\u8bba\u60a8\u9009\u62e9\u54ea\u79cd\u5e93\u6216\u65b9\u6cd5\uff0c\u90fd\u5e94\u6839\u636e\u60a8\u7684\u7279\u5b9a\u9700\u6c42\u8fdb\u884c\u9009\u62e9\u3002\u5728MacOS\u4e0a\u4f7f\u7528Python\u5904\u7406Word\u6587\u6863\u5185\u5bb9\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u6709\u6548\u5730\u5904\u7406\u6587\u6863\u6570\u636e\u3002<\/p>\n<p><strong>Q: Mac\u4e0a\u6709\u6ca1\u6709\u517c\u5bb9Python\u7684Word\u5904\u7406\u5e93\uff1f<\/strong><\/p>\n<p>A: \u662f\u7684\uff0cMacOS\u4e0a\u6709\u4e00\u4e9b\u4e0ePython\u517c\u5bb9\u7684Word\u5904\u7406\u5e93\u53ef\u4f9b\u4f7f\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5e93\uff1a<\/p>\n<ol>\n<li>\n<p><strong>python-docx<\/strong>\uff1a\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u8bfb\u5199Word\u6587\u4ef6\u7684\u6d41\u884cPython\u5e93\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u6253\u5f00\u3001\u4fee\u6539\u548c\u521b\u5efaWord\u6587\u6863\uff0c\u5305\u62ec\u6587\u672c\u3001\u6bb5\u843d\u3001\u8868\u683c\u3001\u6837\u5f0f\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p><strong>python-pptx<\/strong>\uff1a\u5c3d\u7ba1\u5b83\u7684\u540d\u79f0\u4e2d\u5305\u542b\u201cpptx\u201d\uff0c\u4f46\u5b9e\u9645\u4e0a\u8fd9\u4e2a\u5e93\u4e5f\u80fd\u5904\u7406Word\u6587\u6863\u3002\u5b83\u63d0\u4f9b\u4e86\u8bb8\u591a\u65b9\u6cd5\u6765\u8bfb\u53d6\u548c\u4fee\u6539Word\u6587\u6863\u7684\u5185\u5bb9\uff0c\u5982\u6bb5\u843d\u3001\u56fe\u50cf\u3001\u6837\u5f0f\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p><strong>openpyxl<\/strong>\uff1a\u867d\u7136\u8fd9\u4e2a\u5e93\u4e3b\u8981\u7528\u4e8e\u5904\u7406Excel\u6587\u4ef6\uff0c\u4f46\u5b83\u4e5f\u5177\u6709\u5904\u7406Word\u6587\u6863\u7684\u4e00\u4e9b\u529f\u80fd\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528openpyxl\u5e93\u6765\u8bfb\u53d6Word\u6587\u6863\u7684\u7ed3\u6784\u548c\u5c5e\u6027\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u5e93\u4e4b\u4e00\uff0c\u60a8\u53ef\u4ee5\u5728MacOS\u4e0a\u4f7f\u7528Python\u6765\u8bfb\u53d6\u548c\u5904\u7406Word\u6587\u6863\u3002\u8bf7\u6839\u636e\u60a8\u7684\u9700\u6c42\u9009\u62e9\u9002\u5408\u60a8\u7684\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5728MacOS\u4e0b\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u5e93\u6765\u8bfb\u53d6Word\u6587\u4ef6\uff0c\u4f8b\u5982\u4f7f\u7528python-docx\u3001pywin32\uff08\u4ec5 [&hellip;]","protected":false},"author":3,"featured_media":222671,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/222666"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=222666"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/222666\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/222671"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=222666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=222666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=222666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}