Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 24
    @simon 's answer is more flexible and more useful when formatting more complex strings Commented Jul 27, 2013 at 7:08
  • 5
    or @abbot 's if you are stuck supporting old versions of python Commented Jul 27, 2013 at 7:25
  • 3
    ljust() is now deprecated. See stackoverflow.com/questions/14776788/… for the correct way to do it Commented Jan 21, 2015 at 8:41
  • 2
    Its gone in python 3? Just wanted to add there is also rjust and center which work much the same way but for different alignments Commented Jan 22, 2015 at 13:37
  • 30
    ljust(), rjust() have been deprecated from the string module only. They are available on the str builtin type. Commented Jun 30, 2015 at 21:07