samedi 28 mars 2015

Python: How can read as float numbers a series of strings from a text file?

I'm trying to read from a text file line by line a series of strings like these:



11,52.15384615384615,52.84615384615385,14.0,45.15384615384615,39.76923076923077
10,27.09090909090909,54.81818181818182,64.36363636363636,65.54545454545455,21.90909090909091


(The first number is an integer used as index), and what I would like to get are float numbers such as



11, 52.15, 52.85, 14.00, 45.15, 39.77
10, 27.09, 54.82, 64.36, 65,54, 21.91


How can I convert these strings to a list of numbers?


Aucun commentaire:

Enregistrer un commentaire