python - remove all decimals from a float -
how can remove decimal places form float?
a = 100.0
i want become 100
i tried str(a).rstrip('.0'), returned 1
what converting int?
>>>int(a) 100 just sake of completeness, there many many ways remove decimal part string representation of decimal number, 1 can come right is:
s='100.0' s=s[:s.index('.')] s >>>'100' perhaps there's 1 more simple.
hope helps!
Comments
Post a Comment