How can I change '>' to '>' and '>' to '>'? [duplicate]
print u'<'
How can I print <
print '>'
How can I print >
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>
精彩评论