If I have f=123.12
, what is easier way to change to string s="123"
?
For now I do: s = "%.0f" % (f,)
.
If you want to round the value, do:
str(int(f+0.5))
If you want to truncate the value, do:
str(int(f))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With