convert html entities into real chars
Larry Bates
larry.bates at websafe.com
Tue Apr 10 11:33:59 EDT 2007
Laszlo Nagy wrote:
>
> Hi,
>
> I would like to have a function that can convert '>' into '>',
> '&' into '&' etc. I could not find how to do it easily (I have a
> code snippet for the opposite).
> Thanks,
>
> Laszlo
>
You can use htmlentitydefs module to help with this.
import htmlentitydefs
chr(htmlentitydefs.name2codepoint['gt'])
and (to go the other way)
htmlentitydefs.codepoint2name[ord('>')]
-Larry
More information about the Python-list
mailing list