Reputation: 23
How to decode this string in python?
title = 'Fast & Furious 6'
to get:
Fast & Furious 6
Thank you!
Upvotes: 2
Views: 124
Reputation: 14191
Just use the built-in html
module:
import html
decoded_title = html.unescape(title))
as your string consists of HTML-safe sequences (numeric character references).
Upvotes: 0
Reputation: 724
with this code you got char symbol from ascii rappresentation.
title = 'Fast & Furious 6'
title = title[:-1]
substring=[x.strip() for x in title.split(';')]
titleFinal = ''
for ch in substring:
newstr = ch.replace("&#", "")
titleFinal+=chr(int(newstr))
print(titleFinal)
Upvotes: 1