Removing non-breaking spaces from strings using Python
Posted
by dontsaythekidsname
on Stack Overflow
See other posts from Stack Overflow
or by dontsaythekidsname
Published on 2010-04-07T18:13:25Z
Indexed on
2010/04/07
18:33 UTC
Read the original article
Hit count: 373
Hello:
I am having some trouble with a very basic string issue in Python (that I can't figure out). Basically, I am trying to do the following:
'# read file into a string
myString = file.read()
'# Attempt to remove non breaking spaces
myString = myString.replace("\u00A0"," ")
'# however, when I print my string to output to console, I get:
Foo **<C2><A0>** Bar
I thought that the "\u00A0" was the escape code for unicode non breaking spaces, but apparently I am not doing this properly. Any ideas on what I am doing wrong?
© Stack Overflow or respective owner