How to convert " " in a string to blank space?

Fredrik Lundh fredrik at
Mon Oct 30 19:01:15 CET 2006

一首诗 wrote:

> Is there any simple way to solve this problem?

  corresponds to a non-breaking space, chr(160).  if you're only 
dealing with this specific XML/HTML entity, you can do

     text = text.replace(" ", " ")


     text = text.replace(" ", chr(160))

to handle arbitrary entities and character references, pass the data 
through an HTML or XML parser, or use something like:


More information about the Python-list mailing list