I have a script which reads a text file, pulls decimal numbers out of it as strings and places them into a list.
So I have this list:
['0.49', '0.54', '0.54', '0.54', '0.54', '0.54', '0.55', '0.54', '0.54', '0.54',
'0.55', '0.55', '0.55', '0.54', '0.55', '0.55', '0.54', '0.55', '0.55', '0.54']
How do I convert each of the values in the list from a string to a float?
I have tried:
for item in list:
float(item)
But this doesn't seem to work for me.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…