Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active September 28, 2024 17:09
Create HTML File in Python. For more details: https://kb.aspose.com/html/python/create-html-file-in-python/
import aspose.html
import os
from aspose.html import *
path = "C://"
document_path = os.path.join(path, "document.html")
# Initialize an empty HTML document
with HTMLDocument() as document:
# Create a text node
text = document.create_text_node("Hello, World!")
document.body.append_child(text)
# Save the document to a file
document.save(document_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment