Hi all,

I have this unicode string:

string = u'Macworld » Jobs 1 - Twitter 0'

and I want to replace the '»' (aka \xbb) char to '&raquo'.
I've tried 2 ways:

1.
>>> string2 = string.replace('\\xbb','»')
u'Macworld \xbb Jobs 1 - Twitter 0'

2.
>>> import cgi
>>> string2 = cgi.escape(string).encode("ascii", "xmlcharrefreplace")
>>> string2
'Macworld » Jobs 1 - Twitter 0'

None of them gives me 'Macworld » Jobs 1 - Twitter 0'

Any idea?

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to