Categories
Python Answers

How to perform HTML decoding/encoding using Python Django?

Spread the love

To perform HTML decoding/encoding using Python Django, we can use escape and unescape.

For instance, we write

from html import escape

print(escape("<"))

to escape the '<' string.

And we reverse the escaping with

from html import unescape  

print(unescape("&gt;"))

to call unescape to unescape the "&gt;" string.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *