How to write string (float) to file?

Grant Edwards grante at visi.com
Wed Aug 29 09:39:05 EDT 2001


In article <9ZOi7.53225$c8.23251519 at news1.denver1.co.home.com>, Rainer Deyke wrote:
><gbreed at cix.compulink.co.uk> wrote in message
> news:9mfqmi$ko4$1 at thorium.cix.co.uk...
>> 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)
> 
> That's unreliable.  Use this instead:

After reading a handful of follow-ups, I'm still curious what
you mean when you say that's unreliable.

-- 
Grant Edwards                   grante             Yow!  I'm shaving!! I'M
                                  at               SHAVING!!
                               visi.com            



More information about the Python-list mailing list