How to write string (float) to file?

gbreed at cix.compulink.co.uk gbreed at cix.compulink.co.uk
Tue Aug 28 06:10:26 EDT 2001


In article <9mfm1l$gs3$1 at zeus.man.szczecin.pl>, 
piotrlg at sci.pam.szczecin.pl (Piotr Legiecki) wrote:

> How can I tell python to give me only 2 digits after decimal point? And
> of course store it in a variable.
> 
> So I want 'c' to be 3.33.

c = '%.2f'%(float(a)/b)


                      Graham




More information about the Python-list mailing list