pip install markupsafe
python
from markupsafe import escape
html_code = '<script>alert("Hello, World!")</script>'
escaped_code = escape(html_code)
print(escaped_code)
python
from markupsafe import Markup
html_code = Markup('<script>alert("Hello, World!")</script>')
print(html_code)