print u'<'#how can i print '<'
print '>' #how can i print '>'
thanks
print u'<'#how can i print '<'
print '>' #how can i print '>'
thanks
[Obligatory "use a DOM to construct XML, in the name of all that is holy" post.]
You should use HTMLParser module to decode html:
>>> import HTMLParser
>>> h= HTMLParser.HTMLParser()
>>> h.unescape('alpha < β')
u'alpha < \u03b2'
To escape HTML, cgi module is fine:
>>> cgi.escape(u'<a>bá</a>').encode('ascii', 'xmlcharrefreplace')
'<a>bá</a>