how to improve this simple block of code

Xavier Morel xavier.morel at masklinn.net
Wed Jan 11 23:28:08 CET 2006


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.



More information about the Python-list mailing list