Unicode Problem

Bard Aase elzapp at elzapp.com
Thu Oct 30 04:37:31 EDT 2008


On Thu, Oct 30, 2008 at 8:28 AM, Seid Mohammed <seidymam at gmail.com> wrote:
> I am new to python.
> I want to print Amharic character using the Python IDLE.
> here goes somple code
> ==============================================================
>>>> abebe = 'አበበ በሶ በላ'
>>>> abebe
> '\xe1\x8a\xa0\xe1\x89\xa0\xe1\x89\xa0 \xe1\x89\xa0\xe1\x88\xb6
> \xe1\x89\xa0\xe1\x88\x8b'
>>>> print abebe
> አበበ በሶ በላ
>>>> abeba = ['አበበ','በሶ','በላ']
>>>> abeba
> ['\xe1\x8a\xa0\xe1\x89\xa0\xe1\x89\xa0', '\xe1\x89\xa0\xe1\x88\xb6',
> '\xe1\x89\xa0\xe1\x88\x8b']
>>>> print abeba
> ['\xe1\x8a\xa0\xe1\x89\xa0\xe1\x89\xa0', '\xe1\x89\xa0\xe1\x88\xb6',
> '\xe1\x89\xa0\xe1\x88\x8b']
>>>> len(abebe)
> 23
> ========================
> so my question is
> 1)why >>> abebe prints  '\xe1\x8a\xa0\xe1\x89\xa0\xe1\x89\xa0
> \xe1\x89\xa0\xe1\x88\xb6 \xe1\x89\xa0\xe1\x88\x8b' instead of አበበ በሶ
> በላ
> 2) why >>> print abeba don't print the expected አበበ በሶ በላ string


when you print strings from the interpreter using >>> abeba it will
escape any non-ascii characters.
if you, instead print it using >>> print abeba it will print the
proper characters, as long as your terminal supports it.


-- 
mvh base (Bård Aase)
MSN: msn at elzapp.com
http://blog.elzapp.com
:wq


More information about the Python-list mailing list