printing list containing unicode string
Xah Lee
xah at xahlee.org
Mon Sep 10 18:14:51 EDT 2007
On Sep 10, 8:12 am, Carsten Haese <cars... at uniqsys.com> wrote:
Xah Lee wrote:
If i have a nested list, where the atoms are unicode strings, e.g.
# -*- coding: utf-8 -*-
ttt=[[u"→",u"↑"], [u"αβγ"],...]
print ttt
how can i print it without getting the u'\u1234' notation?
i.e. i want it print just like this: [[u"→"], ...]
Carsten Haese wrote:
It's not quite clear why you want to do this, but this is how you
could
do it:
print repr(ttt).decode("unicode_escape").encode("utf-8")
Super! Thanks a lot.
About why i want to... i think it's just simpler and easier on the
eye?
here's a example output from my program:
[[u' ', 1022], [u'↑', 472], [u' ', 128], [u'→w', 300], [u'→s', 12],
[u'→|', 184],...]
wouldn't it be preferable if Python print like this by default...
Xah
xah at xahlee.org
∑ http://xahlee.org/
More information about the Python-list
mailing list