lets say I have a a string such as :
line = "tree length for XI: 31.0215"
I would liek to only keep the 31.0215
part.
I tried:
print (re.sub("^[0-9]", "",line))
but it does not work, the "." is removed, does anyone have an idea?
lets say I have a a string such as :
line = "tree length for XI: 31.0215"
I would liek to only keep the 31.0215
part.
I tried:
print (re.sub("^[0-9]", "",line))
but it does not work, the "." is removed, does anyone have an idea?
You can try this out.
line = "tree length for XI: 31.0215"
for item in line.split():
try:
float(item)
print(float(item))
except:
pass