Converting exponential numbers to strings.
steve
steve at clublinux.org
Tue Nov 6 08:17:53 EST 2001
Hi,
> How about this:
> try:
> x = float(s)
> result = 1
> except:
> result = 0
Genious. Short and simple. I like it. Thank you.
One more question about string processing. I've written a small report
formating routine that prints everything as strings. The reason for
this is that I want to be able to add commas, floating dollar signs,
etc. to the report and printing everything as a string seemed to be the
easiest way to perform such tasks.
I run into the same problem when trying to process the string from
printing when I use the str() function. Is there another way to convert
a number to a string that will return the number in a non-exponential
format?
(e.g. return .000085 instead of 8.5e-5?)
Thanks again for your help,
Steve
More information about the Python-list
mailing list