from lxml.builder import E from lxml import etree print etree.tostring(E.p(u'\xc3\xbf')) print etree.tostring(E.p('\xc3\xbf'.decode('utf-8'))) print etree.tostring(E.p('\xc3\xbf'.decode('utf-8')), encoding='utf-8')