'\xc3\xa9'
is the UTF-8 encoding of the unicode character u'\u00e9'
(which can also be specified as u'\xe9'
). So you can use u'Andr\u00e9'
or u'Andr\xe9'
.
You can convert from one to the other:
>>> 'Andr\xc3\xa9'.decode('utf-8')
u'Andr\xe9'
>>> u'Andr\xe9'.encode('utf-8')
'Andr\xc3\xa9'
Note that the reason print 'Andr\xc3\xa9'
gave you the expected result is only because your system's default encoding is UTF-8. For example, on Windows I get:
>>> print 'Andr\xc3\xa9'
André
As for outputting HTML, it depends on which web framework you use and what encoding you output in the HTML page. Some frameworks (e.g. Django) will convert unicode values to the correct encoding automatically, while others will require you to do so manually.