Python String Formatting

24 Nov 2013

Formatting texts is a common task a programmer encounters. Python language has provided a format method for string module. This newly introduced (since 2.6) method is the standard preferred way to format texts in Python.

The introduction of the syntax is here. The syntax uses a Format Specification Mini-Language, which I found quite flexible and powerful and easy to use.

Of course, it’s better to learn by some examples. Also, this blog post contains some useful number-formatting examples to get your started.