stepper_m
stepper_m

Reputation: 63

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ö")
----
  Ho
 Hö

so, what am i doing wrong ?

Upvotes: 1

Views: 217

Answers (1)

twobit
twobit

Reputation: 61

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ö")

Upvotes: 1

Related Questions