New Python 3.0 string formatting - really necessary?

MRAB google at mrabarnett.plus.com
Sat Dec 20 20:28:15 EST 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