Python 3 Script to Escape and Unescape HTML Entities to String Using HTML Module Full Project For Beginners

Python 3 Script to Escape and Unescape HTML Entities to String Using HTML Module Full Project For Beginners

 

Welcome folks today in this tutorial we will be escaping and unescaping html entities to text or string in python using the html module. All the full source code of the application will be given below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install html

 

After installing the library make an app.py file and copy paste the following code to it

 

app.py

 

 

## Preliminaries
import html
## Create Text
text = 'This item costs ¥400 or £4.'
## Convert To String
print(html.unescape(text))
'This item costs ¥400 or £4.'
## Convert To HTML Entities
print(html.escape(text))

 

 

So now when you execute the python script app.py by typing the below command as shown below

See also  Python 3 (OpenCV + Numpy + Qrcode) Example Script to Scan or Read Qr Codes and Generate QR Codes Full Example Project For Beginners

 

 

python app.py

 

 

 

Leave a Reply