Let's say I read from a file, called 'info.dat', containing this:
[{'name': 'Bob', 'occupation': 'architect', 'car': 'volvo'}, {'name': 'Steve', 'occupation': 'builder', 'car': 'Ford'}]
How could I read this and turn it into a list of dictionaries? If I do this:
with open('info.dat') as f:
data = f.read()
It just reads it into a single string, and even if I do this to break it up:
data = data[1:-1]
data = data.split('},')
I still have to get it into a dictionary. Is there a better/cleaner way to do this?