I have a input file Input.txt and in the input I have content as
Name1=Value1
Name2=Value2
Name3=Value3
Now from the input file, I'm able to split the values as per new line. Next task is to store the name and value pairs in Dictionary. I tried by the following method,
with open("Input.txt", "r") as param_file:
for line in param_file:
str = line.split()
d = dict(x.split("=") for x in str.split("\n"))
for k,v in d.items():
print(k, v)
but this is giving me error as: AttributeError: 'list' object has no attribute 'split' I know that the list does not have split function that's why I'm getting this. What could be the correct way to implement this?
Expected output is:
Name1 Value1
Name2 Value2
Name3 Value3