Encode differences between idle python and python
Gabriel Genellina
gagsl-py at yahoo.com.ar
Tue Oct 10 03:24:52 EDT 2006
At Tuesday 10/10/2006 02:44, pretoriano_2001 at hotmail.com wrote:
>Hello:
>Under win32 XP y select python command line and execute next code with
>results indicated:
>
>Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
>(Intel)] on
>Type "help", "copyright", "credits" or "license" for more information.
> >>> u=u'áéíóú'
> >>> u
>u'\xe1\xe9\xed\xf3\xfa'
> >>> print u
>áéíóú
> >>> a=u.encode('latin-1')
> >>> a
>'\xe1\xe9\xed\xf3\xfa'
> >>> print a
>ßÚݾ·
> >>> type(a)
><type 'str'>
> >>> type(u)
><type 'unicode'>
> >>>
Because the console code page != windows code page.
Exit Python. At the console prompt, type:
>chcp
If it says 850 - your console is using codepage 850.
Enter Python again, and replace 'latin-1' with
'cp850'. You should get the right representation.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
More information about the Python-list
mailing list