You need to indicate that the second line is Unicode, placing ubefore the line:
>>> str1="Adam Matan"
>>> str2=u"אדם מתן"
>>> print "X %20s X" % str1
X Adam Matan X
>>> print "X %20s X" % str2
X אדם מתן X
This allows Python to know that it counts Unicode characters, not just bytes.
tghw source
share