I'd prefer a more generalized solution which takes care of all possible
ampersand characters. I assume that there is code already written which
does this.
Thanks
i80and wrote:
I would suggest using string.replace. Simply replace ' ' with ' '
for each time it occurs. It doesn't take too much code.
>
On Nov 7, 1:34 pm, "mp" <mailpitc...@em ail.comwrote:
I have html document titles with characters like >, , and
‡. How do I decode a string with these values in Python?
>I'd prefer a more generalized solution which takes care of all possible
>ampersand characters. I assume that there is code already written which
>does this.
Try the htmlentitydefs module
--
Gabriel Genellina
Softlab SRL
_______________ _______________ _______________ _____
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
I have html document titles with characters like >, , and
‡. How do I decode a string with these values in Python?
>
Thanks
>
>
This is definitely the most FAQ. It comes up about once a week.
The stream-editing way is like this:
>>import SE
>>HTM_Decoder = SE.SE ('htm2iso.se') # Include path
>>test_string = '''I have html document titles with characters like >, , and
. How do I decode a string with these values in Python?'''
>>print HTM_Decoder (test_string)
I have html document titles with characters like >, , and
‡. How do I decode a string with these values in Python?
An SE object does files too.
>>HTM_Decoder ('with_codes.tx t', 'translated_cod es.txt') # Include path
You could download SE from -http://cheeseshop.python.org/pypi/SE/2.3. The translation definitions file "htm2iso.se " is included. If you open it in your editor, you can see how to write your own definition files for other translation tasks you may have some other time.
Comment