Instead of strip, select for the numbers with a regular expression:
import re
numbers = re.compile(r'\d+(?:\.\d+)?')
numbers.findall("It took 2.3 seconds")
Demo:
>>> import re
>>> numbers = re.compile(r'\d+(?:\.\d+)?')
>>> numbers.findall("It took 2.3 seconds")
['2.3']
This returns a list of all matches; this lets you find multiple numbers in a string too:
>>> numbers.findall("It took between 2.3 and 42.31 seconds")
['2.3', '42.31']