1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

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

        共 1283字,需瀏覽 3分鐘

         ·

        2021-09-12 21:48



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



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

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            少妇在线视频 | 中国一级黄片操逼 | 大奶网站 | 亚洲无码TV | 欧美bbbbb性bbbbb视频 | 巨肉黄暴辣文高h公主 | 在线看欧美黄片 | 人妻综合网 | 3级片在线 | 91九色免费视频 |