Reading a comma delimited file
Kristen Zander
kzander at hot.rr.com
Thu Nov 8 12:42:19 EST 2001
That cleared up alot becuase it was really becoming frustrating.
I just figured it out.
import fpformat
a = 97.33532356246
b = fpformat.fix(a,2)
print b
97.33
Great! Thanks.
Skip Montanaro <montanaro at tttech.com> wrote in message
news:E161rjE-00027T-00 at ttt17.tttech1.ttt...
>
> Kristen> Here's what it looks like when I'm done:
>
> Kristen> [('Cotulla', 28.449999999999999, 99.216700000000003,
1960.0, 2.0, 11.1,
> Kristen> 20.0, 0.0, 167.30000000000001),
> Kristen> ('Cotulla', 28.449999999999999, 99.216700000000003,
1960.0, 3.0,
> Kristen> 6.0999999999999996, 13.9, 0.0, 239.0)]
>
> Kristen> Just what I need except I don't want all those decimal
places.
>
> You're being victimized by floating point (im)precision. Details here:
>
> http://python.sourceforge.net/devel-docs/tut/node14.html
> http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp
>
> --
> Skip Montanaro (skip at pobox.com)
> http://www.mojam.com/
> http://www.musi-cal.com/
More information about the Python-list
mailing list