You can read the contents of the "file" (or in this case, the input string) using the np.genfromtxt function, and fit the data using np.linalg.lstsq.