How do I unescape HTML entities in a string in Python 3.1?
You can use xml.sax.saxutils.unescape
for this purpose. This module is included in the Python standard library, and is portable between Python 2.x and Python 3.x.
>>> import xml.sax.saxutils as saxutils
>>> saxutils.unescape("Suzy & John")
'Suzy & John'
You could use the function html.unescape:
In Python3.4+ (thanks to J.F. Sebastian for the update):
import html
html.unescape('Suzy & John')
# 'Suzy & John'
html.unescape('"')
# '"'
In Python3.3 or older:
import html.parser
html.parser.HTMLParser().unescape('Suzy & John')
In Python2:
import HTMLParser
HTMLParser.HTMLParser().unescape('Suzy & John')