printing a list with non-ascii strings

Peter Otten __peter__ at web.de
Thu Jan 20 13:42:10 EST 2011


Helmut Jarausch wrote:

> I don't understand Python's behaviour when printing a list.
> The following example uses 2 German non-ascii characters.
> 
> #!/usr/bin/python
> # _*_ coding: latin1 _*_
> L=["abc","süß","def"]
> print L[1],L
> 
> The output of L[1] is correct, while the output of L shows up as
>  ['abc', 's\xfc\xdf', 'def']
> 
> How can this be changed?

Use unicode and follow Martin's recipe:

http://mail.python.org/pipermail/python-list/2011-January/1263783.html



More information about the Python-list mailing list