Konversi String ke Daftar Kamus
import ast
ast.literal_eval(string_data)
Faithful Flatworm
import ast
ast.literal_eval(string_data)
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 )
import json
var = ["[{'Gfg' : 3, 'Best' : 8}, {'Gfg' : 4, 'Best' : 9}]"]
new_var = [json.loads(idx.replace("'", "'")) for idx in test_str]