How to convert " " in a string to blank space?
Fredrik Lundh
fredrik at pythonware.com
Mon Oct 30 13:01:15 EST 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(" ", " ")
or
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:
http://effbot.org/zone/re-sub.htm#unescape-html
</F>
More information about the Python-list
mailing list