File Attributes conversion
Chris Barker
Chris.Barker at noaa.gov
Fri Mar 8 15:10:59 EST 2002
Sam Collett wrote:
>
> How would you remove trailing 0's?
> e.g.
> Instead of 12.20kb it would be 12.2kb
> 23kb instead of 23.00 etc
I don't see a way to do it with format specifiers. %g doesn't print
trailing zeros, but it goes into exponential notation for larger values.
If you were sure if your values, you might be able to use it.
Otherwise, you can write a little function with string methods (or maybe
even a regular expression) that would strip them off for you.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Python-list
mailing list