The inverse of number formatting is just float()
:
x = float("5.09000")
I would recommend just converting everything to float, not a mix of floats and ints-- a mix means that your code never knows which data type is at hand. Anyway you can drop all-zero decimal parts on printing.
line = "1 5.090000 77"
numbers = [ float(n) for n in line.split() ]
But if you really want your data to be a mix of floats and ints, you can do it like this:
numbers = [ (float(n) if "." in n else int(n)) for n in line.split() ]
If you need to specify in advance which format will be used for each number (regardless of what the input looks like), then just use @BurhanKhalid's answer. E.g., if you want the first number to become a float even if it is given as "3"; but note that if an int is expected and you see "2.0", you'll get an error with that approach.
5.09
from5.090000
?float('5.090000')
.