Recap of .format() method (here for a more detailed description). NB: Multiple spaces are represented with underscores.


'{:4d}'.format(42)

“__42”


'{:06.2f}'.format(3.141592653589793)

“003.14”


'{:.2e}'.format(100000)

“1.00e+05”


'{}, {}'.format('one', 'two')

“one, two”


'{1}, {0}'.format('one', 'two')

“two, one”


'{:>10}'.format('test')

____test”


'{:10}'.format('test')

“test____


'{:<{}s}'.format('test', 8)

“test____”


'{:^10}'.format('test')

“__ test __”