[docs] http://docs.python.org/2/library/string.html#format-string-syntax

Martin Herweg m.herweg at gmx.de
Mon Dec 3 21:40:07 CET 2012


http://docs.python.org/2/library/string.html#format-string-syntax

I suggest to change the examples so that they also work in Python 2.6
or add a comment to each line that it requires Python 2.7

It did bite me on android: PythonAPK is 2.7 but Py4A is still 2.6



Aligning the text and specifying a width:

>>> '{:<30}'.format('left aligned')
'left aligned                  '
>>> '{:>30}'.format('right aligned')
'                 right aligned'
>>> '{:^30}'.format('centered')
'           centered           '
>>> '{:*^30}'.format('centered')  # use '*' as a fill char
'***********centered***********'




thank you!



More information about the docs mailing list