Replace special characters in python

Posted by Marcos Placona on Stack Overflow See other posts from Stack Overflow or by Marcos Placona
Published on 2011-01-16T14:10:05Z Indexed on 2011/01/16 14:53 UTC
Read the original article Hit count: 166

Filed under:
|

Hi, I have some text coming from the web as such:

£6.49

Obviously I would like this to be displayed as:

£6.49

I have tried the following so far:

s = url['title']
s = s.encode('utf8')
s = s.replace(u'Â','')

And a few variants on this (after finding it on this very same forum)

But still no luck as I keep getting:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 100: ordinal not in range(128)

Could anyone help me getting this right?

UPDATE:

Adding the reppr examples and content type

u'Star Trek XI £3.99'
u'Oscar Winners Best Pictures Box Set \xc2\xa36.49'
Content-Type: text/html; charset=utf-8

Thanks in advance

© Stack Overflow or respective owner

Related posts about python

Related posts about string