python str to list of dicts code example
Example 1: convert string to list of dictionaries
import ast
ast.literal_eval(string_data)
Example 2: python convert string to list of dictionaries
import json
with open('.listOfDicts.txt', 'r') as file:
dataList = json.loads(file.read().replace('\n', ''))
for dictItem in dataList:
for key , val in dictItem.items():
print( key , val )