how to make format operator % work with unicode as expected
Peter Pei
yantao at telus.com
Sun Jan 27 00:32:40 EST 2008
You didn't understand my question, but thanks any way.
Yes, it is true that %s already support unicode, and I did not contradict
that. But it counts the number of bytes instead of characters, and makes
things like %-20s out of alignment. If you don't understand my assertion,
please don't argue back and I am only interested in answers from those who
are qualified.
==============================================================
"Steven D'Aprano" <steve at REMOVE-THIS-cybersource.com.au> wrote in message
news:13po55nc0q0s06 at corp.supernews.com...
> On Sun, 27 Jan 2008 04:06:45 +0000, Peter Pei wrote:
>
>> I probably should mention that what I want is to make all parts of the
>> string aligned, and look like table. I am not looking for other ways to
>> make it table-alike, but only interested in making % work with unicode
>> -counting characters not bytes...
>
> % already works with unicode. Just give it unicode arguments:
>
>
>>>> print u"x y z %s 1 2 3" % u"Les misérables"
> x y z Les misérables 1 2 3
>
>
> --
> Steven
More information about the Python-list
mailing list