printing a list with non-ascii strings

Benjamin Kaplan benjamin.kaplan at case.edu
Thu Jan 20 11:03:32 EST 2011


On Thu, Jan 20, 2011 at 10:43 AM, Helmut Jarausch <jarausch at skynet.be>wrote:

> Hi,
>
> 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?
>
> Thanks for hint,
> Helmut.
>
>
Use Python 3 if you can. Printing a list calls the repr(). In python 2, that
showed the bytes for non-ascii characters. Python 3 will print the
characters.

> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110120/508d53ba/attachment.html>


More information about the Python-list mailing list