Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'module' object has no attribute 'unescape'

Tags:

python

This code works perfectly on the console but when I implement it in my flask application it says that there's an AttributeError

        clean = html.unescape(tweet.text)

        final = re.sub(r'\w+:\/{2}[\d\w-]+(\.[\d\w-]+)*(?:(?:\/[^\s/]*))*', '', clean)

I also tried import html inside the for loop

and from html import unescape

like image 202
Blacksun Avatar asked Aug 07 '17 19:08

Blacksun


1 Answers

Please note that HTMLParser.unescape was removed from Python since version 3.9.0a1.

Update (due to popular demand)

Beginning with Python 3.4 you can use html.unescape, see https://docs.python.org/3/library/html.html

like image 100
Jürgen Gmach Avatar answered Oct 18 '22 06:10

Jürgen Gmach