Display number for preferred format

Hi

       How to do this

        for redundant number;
         num = 234.23434334
         num_string =str(round( num,3))

         but for;
          float = 234.0
          I would like to display;
          string = 234.000

Regard
chatchai

···

_________________________________________________________________
Don�t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

Monday, September 12, 2005, 1:27:48 AM, Chatchai Nanudorn wrote:

       How to do this

        for redundant number;
         num = 234.23434334
         num_string =str(round( num,3))

         but for;
          float = 234.0
          I would like to display;
          string = 234.000

num_string = str(round(num, 3))
num_string += (3 - len(num_string.split(".")[1])) * "0"

-- tacao

No bits were harmed during the making of this e-mail.

*From:* "E. A. Tacao"

Monday, September 12, 2005, 1:27:48 AM, Chatchai Nanudorn wrote:

> How to do this

> for redundant number;
> num = 234.23434334
> num_string =str(round( num,3))

> but for;
> float = 234.0
> I would like to display;
> string = 234.000

num_string = str(round(num, 3))
num_string += (3 - len(num_string.split(".")[1])) * "0"

num_string = "%.3f" % num

David