stepper_m stepper_m - 6 months ago 24
Python Question

Python print format umlaut align right

I am trying to print text aligned right containing a german umlaut. This is, what the python interpreter produces:

>>> print "----\n{:>4}\n{:>4}".format("Ho", "Hö")

so, what am i doing wrong ?


Just let python know that you're leading with UTF-8 strings by adding a u in front of the string literal.

print u"----\n{:>4}\n{:>4}".format("Ho", u"Hö")