Python 2.7.3
>>> print '%2.2f' % 0.1
0.10
The documentation I have says that type % should be the same as type f except that the input is multiplied by 100.
>>> print '%2.2%' % 0.1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
use the new format expression, which has the formatter you are referring to
if you just want the integer part you can use the precision specification
see the doc at
http://docs.python.org/2/library/string#formatspec
To expand a little bit, the new format specificator is really more powerful than the old one. First of all it’s really simple calling the parameters by order or name
then, as can be seen in the documentation, is possible to have access to properties of the object:
There is a lot more than this, but you can find it all in the documentation, that is very clear.