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

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -