I am trying to read a Fortran double precision number, e.g. 1.2345D + 02, in python, but I got the following error:
>>> float('1.2345D+02') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for float(): 1.2345D+02
Following the advice of Python scientific notation using D instead of E , I tried numpy but also get the same error:
import numpy >>> numpy.float("1.2345D+02") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for float(): 1.2345D+02
Does Python have a solution for reading these double-precision numbers without changing the "D" to the "E"?
EDIT: I replaced the bad syntax with strings. But still I get errors.
source share