New Python 3.0 string formatting - really necessary?

MRAB google at mrabarnett.plus.com
Sun Dec 21 02:28:15 CET 2008


r wrote:
> Thanks MRAB,
> except the float is not 2 decimal places, but its there
> 
Oops!

 >>> '{0} {1:05} {2:.2f}'.format(s, n, f)
'python 00012 1.33'
 >>> '{0:s} {1:05d} {2:.2f}'.format(s, n, f)
'python 00012 1.33'



More information about the Python-list mailing list