print u'<'如何打印<
print '>' 如何打印>
发布于 2009-12-30 19:00:15
你应该使用HTMLParser模块来decode html
>>> import HTMLParser
>>> h= HTMLParser.HTMLParser()
>>> h.unescape('alpha < β')
u'alpha < \u03b2'要转义HTML,cgi module is fine
>>> cgi.escape(u'<a>bá</a>').encode('ascii', 'xmlcharrefreplace')
'<a>bá</a>https://stackoverflow.com/questions/1977900
复制相似问题