I have to read a data file that contains numbers formatted with (very) old FORTRAN style. A line of the file looks like this:
4.500000+1 1.894719-3 4.600000
this should work:
In [47]: strs="4.500000+1 1.894719-3 4.600000+1 8.196721-3 4.700000+1 2.869539-3" In [48]: [float(x.replace("+","e+").replace("-","e-")) for x in strs.split()] Out[48]: [45.0, 0.001894719, 46.0, 0.008196721, 47.0, 0.002869539]