Mel Wilson wrote: > py wrote: >> Say I have... >> x = "132.00" >> >> but I'd like to display it to be "132" ...dropping the trailing >> zeros... > > print '%g' % (float(x),) > > might work. > > Mel. > The input is a string, %g expects a float, TypeError exception. -- http://mail.python.org/mailman/listinfo/python-list
- Re: how to improve this simple block of code Xavier Morel
- Re: how to improve this simple block of code Xavier Morel
- Re: how to improve this simple block of code Peter Hansen
- Re: how to improve this simple block of code Tim Williams (gmail)
- Re: how to improve this simple block of code Steven D'Aprano