Floating numbers and str

Tuvas tuvas21 at gmail.com
Wed Nov 9 14:52:29 EST 2005


I would like to limit a floating variable to 4 signifigant digits, when
running thorugh a str command. Ei,


x=.13241414515
y=str(x)+" something here"

But somehow limiting that to 4 sign. digits. I know that if you use the
print statement, you can do something like %.4d, but how can I do this
with converting the number to a string? Thanks!




More information about the Python-list mailing list