Unicode char replace
DiMar
divinmarchese at gmail.com
Tue Feb 12 15:54:28 EST 2008
Hi all,
I have this unicode string:
string = u'Macworld » Jobs 1 - Twitter 0'
and I want to replace the '»' (aka \xbb) char to '»'.
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!
More information about the Python-list
mailing list