Skip to content Skip to sidebar Skip to footer

Python3 Convert All Characters To Html Entities

I'm using Python3 and I wonder if there is a module or a default function for converting all characters of a text to html entities (even the letters and digits) because I don't wan

Solution 1:

If you want to really escape all characters, there is no default function for that, but you can just replace each character with the ordinals manually:

''.join('&%d;'.format(ord(x)) for x in string)

Post a Comment for "Python3 Convert All Characters To Html Entities"