possible to round number and convert to string?
Dr. Phillip M. Feldman
pfeldman at verizon.net
Fri Jul 31 20:42:57 EDT 2009
This was very close to what I wanted. Thanks! My final code looks like
this:
def num2str(x,f=4):
"""Convert x (int or float) to a string with f digits to right of
the decimal point. f may be zero or negative, in which case the decimal
point is suppressed."""
s= str(round(x,f))
if f<=0:
# Delete decimal point:
i= s.find('.')
if i>0: s= s[:i]
return s
--
View this message in context: http://www.nabble.com/possible-to-round-number-and-convert-to-string--tp24763821p24764948.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list