Title: Convert HTML Characters To Strings
Slug: convert_html_symbols_to_strings
Summary: Convert HTML Characters To Strings Using Python.
Date: 2017-02-02 12:00
Category: Python
Tags: Basics
Authors: Chris Albon


In [1]:
## Preliminaries

In [2]:
import html

In [3]:
## Create Text

In [4]:
text = 'This item costs ¥400 or £4.'

In [5]:
## Convert To String

In [6]:
html.unescape(text)


Out[6]:
'This item costs ¥400 or £4.'

In [7]:
## Convert To HTML Entities

In [8]:
html.escape(text)


Out[8]:
'This item costs ¥400 or £4.'