Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

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.

5
  • print "'%-6s'" % 'hi' indeed!! Commented Apr 15, 2011 at 12:44
  • 9
    @simon as someone stuck on a python2.5 system this answer helped me, not a useless answer +1 Commented Jul 5, 2014 at 11:49
  • 20
    Not deprecated any more in 3.3+ Commented Feb 16, 2015 at 11:23
  • 4
    I like this common printf syntax much better. Allows you to write complex strings without countless concatenations. Commented Jun 8, 2015 at 9:22
  • 7
    For completeness, "'%+100s'" % 'hi' would work for putting spaces to the right of 'hi' Commented May 8, 2018 at 20:44

lang-py