<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          使用 Python 將 Word 文檔轉(zhuǎn)換為 HTML 或 Markdown

          共 1283字,需瀏覽 3分鐘

           ·

          2021-09-12 21:48



          這篇簡(jiǎn)短的文章將指導(dǎo)您如何在基于 Python 的 CLI  Mammoth的幫助下,以簡(jiǎn)單的方式將 .docx word 文檔轉(zhuǎn)換為簡(jiǎn)單的網(wǎng)頁(yè)文檔 ( .html ) 或 Markdown 文檔 ( .md ) 。



          據(jù)統(tǒng)計(jì)Statista調(diào)查(202016日),Microsoft Office套件是目前最流行的辦公軟件。您可以使用 Microsoft Word 輕松地做快速筆記、簡(jiǎn)短報(bào)告、教程文檔等。而且,您可能希望將文檔內(nèi)容作為 Web 文檔 ( .html )) 或 Markdown 文檔 ( .md )與您的一些朋友、同事、客戶共享。過(guò)去,在網(wǎng)絡(luò)上托管一些網(wǎng)絡(luò)文檔可能會(huì)很昂貴,但現(xiàn)在云服務(wù)對(duì)于公共文檔(例如GitHub Pages)來(lái)說(shuō)非常便宜甚至免費(fèi)。


          Install Mammoth

          確保PC 上安裝了 Python 和 PIP。然后,打開 CMD 或終端并使用以下命令:

          pip install mammoth


          Docx 轉(zhuǎn)換為HTML

          使用命令行:

          $ mammoth input_name.docx output_name.html


          使用Python

          import mammothwith open("sample.docx", "rb") as docx_file:    result = mammoth.convert_to_html(docx_file)with open("sample.html", "w") as html_file:    html_file.write(result.value)


          Docx 轉(zhuǎn)換為MD

          使用命令行:

          $ mammoth .\sample.docx output.md --output-format=markdown


          使用Python

          with open("sample.docx", "rb") as docx_file:    result = mammoth.convert_to_markdown(docx_file)with open("sample.md", "w") as markdown_file:    markdown_file.write(result.value)

          文章轉(zhuǎn)載:Python編程學(xué)習(xí)圈
          (版權(quán)歸原作者所有,侵刪)

          點(diǎn)擊下方“閱讀原文”查看更多

          瀏覽 77
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  丁香五月网 | 欧美日韩逼| porncao1 | 国产青青操视频 | 欧美毛片一区二区三区有限公司 |