Encode differences between idle python and python

pretoriano_2001 at hotmail.com pretoriano_2001 at hotmail.com
Tue Oct 10 01:44:31 EDT 2006


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'>
>>>

using python IDLE I repeat the code, but get next differen result:
IDLE 1.2
>>> 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'>
>>>

What do you think is happending and how can I solve this ? The IDLE
looks fine but command line has problems.




More information about the Python-list mailing list