what module can do html encoder??
richard
richardjones at optushome.com.au
Mon Dec 13 00:50:30 EST 2004
Leon wrote:
> example:
> s = ' ' --->
That's technically not HTML encoding, that's replacing a perfectly valid
space character with a *non-breaking* space character. If that's all you
want to do, then:
s.replace(' ', ' ')
will do it. If, however, you wish to quote special HTML chars, like <, > and
&, then:
cgi.escape(s)
will do that for you. From the library reference for "escape(
s[, quote])":
Convert the characters "&", "<" and ">" in string s to HTML-safe
sequences. Use this if you need to display text that might contain such
characters in HTML. If the optional flag quote is true, the double-quote
character (""") is also translated; this helps for inclusion in an HTML
attribute value, as in <A HREF="...">.
Richard
More information about the Python-list
mailing list