I have a file input.dat with contents:
1.00000000 1.00000000 0.00000000 0.10000000 12 12 50000 2
I want to read these values and assign them to variables a1 to a8 respectively.
I try:
with open("input_params.dat","r") as inpfl:
a1,a2,a3,a4,a5,a6,a7,a8 = inpfl.read()
and get the error:
ValueError: too many values to unpack (expected 8)
How can I modify read() to do what I want?
I also need a1,..., a8 to be floats and integers respectively and not string variables. How do I accomplish this?
inpfl.read().split()a1,a2, ...,a8. Either use sensible names or use a list.