slopeofhope
slopeofhope

Reputation: 776

i cannot get rid \xa0 in this string using python?

here is the code:

shipping_info = u'Expedited (2-3 Bus. Days)\xa0($17.99)'

I cannot get it to replace \xa0 using the method like replace.

here is what i tried:

 x.replace('\\xa0', ' ')
 x.replace(')\xa0(', " ")
 x.replace(unichr(160), " ")

Upvotes: 2

Views: 395

Answers (1)

falsetru
falsetru

Reputation: 369354

Specify u'\xa0' using unicode literal:

>>> shipping_info = u'Expedited (2-3 Bus. Days)\xa0($17.99)'
>>> shipping_info.replace(u'\xa0', u' ')
u'Expedited (2-3 Bus. Days) ($17.99)'

Upvotes: 3

Related Questions