Cutting off trailing zeroes?

Gerrit Holl gerrit.holl at pobox.com
Sat Jan 29 08:27:14 EST 2000


Janos Blazi wrote on 949137250:
> Id like to format a string like this:
>   s = "(%f)" % x
> 
> Now if x=1.5 then s="1.50000" or something like this. Is there a tirivial
> way of cutting of the zeroes, i.e. getting s="1.5" instead of s="1.50000"?
> 
> Of course it can be programmed very simply. My question is: can I do it with
> specifiers somehow?

s = "(%s)" % str(x)

regards,
Gerrit.

-- 
Please correct any bad English you encounter in my email message!
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----




More information about the Python-list mailing list