在 Python 中編輯 HTML

用於使用 Python 代碼編輯 HTML 的高速跨平台 Python 庫

使用 Aspose.Slides 編輯 HTML

Aspose.Slides for Python via .NET 是一個功能強大的 Python 庫,用於操作和編輯演示文稿、HTML 文檔和其他文件.您可以通過向其中添加新的文本行來編輯 HTML 文檔。

在 Python 中編輯 HTML

使用 Aspose.Slides for Python via .NET ,您只需幾行即可將新的文本行添加到 HTML 文檔代碼行。

用於編輯 HTML 的 Python 代碼


import aspose.slides as slides

with slides.Presentation() as pres:
    pres.slides.remove_at(0)
    with open("page.html", "rt") as stream:
        data = stream.read()
    pres.slides.add_from_html(data)

    shape = pres.slides[0].shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 10, 10, 100, 50)
    shape.text_frame.text = "New text"

    pres.save("page.html", slides.export.SaveFormat.HTML5)

如何在 Python 中編輯 HTML

  1. 通過 .NET 安裝 Aspose.Slides for Python。請參閱 安裝 。

  2. 添加庫作為項目中的引用。

  3. 創建一個 Presentation 類的實例。

  4. 加載要編輯的 HTML 文檔。

  5. 添加新的文本行。

  6. 保存更改後的 HTML 文件。

編輯其他文件

您還可以編輯其他格式的文件