This is explained in the Python documentation. In short,
%d
will format a number for display.
%s
will insert the presentation string representation of the object (i.e. str(o)
)
%r
will insert the canonical string representation of the object (i.e. repr(o)
)
If you are formatting an integer, then these are equivalent. For most objects this is not the case.