python处理txt文件,怎么把文本形式的数据处理成字典

如下:

{"item_id": 4036886, "title_features": {"1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1}}
{"item_id": 2893187, "title_features": {"8": 1, "9": 1, "7": 1}}
{"item_id": 338441, "title_features": {"16": 1, "17": 1, "18": 1, "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1}}
{"item_id": 2508763, "title_features": {"72": 1, "73": 1, "74": 1, "75": 1, "71": 1}}
{"item_id": 305495, "title_features": {"80": 1, "76": 1, "77": 1, "78": 1, "79": 1}}
{"item_id": 3096313, "title_features": {"81": 1, "82": 1, "83": 1, "84": 1, "85": 1, "86": 1}}

节选了一段储存在文本文档里的数据,形式是字典的样子,怎么能处理成字典的储存方式呢?
谢谢各位前辈了!

曹老师回答的是核心API,我测试了下实现代码:

import json
f = open("info.txt")
line = f.readline()
while line:
    #dump将字符串转换成字典
    d1=json.loads(line)
    print (type(d1))
    print (d1['item_id'])
    line = f.readline()

f.close()

只用loads就能将字符转成字典了,加上dumps后转成的就是字符类型。
运行结果:

<class 'dict'>
4036886
<class 'dict'>
2893187
<class 'dict'>
338441
<class 'dict'>
2508763
<class 'dict'>
305495
<class 'dict'>
3096313

import json

d = 从你文本文件读取的字符串
j = json.dumps(d)
d1 = json.loads(j)
d1就是你要的

dumps():将字典转换为JSON格式的字符串

loads():将JSON格式的字符串转化为字典

dump():将字典转换为JSON格式的字符串,并将转化后的结果写入文件

load():从文件读取JSON格式的字符串,并将其转化为字典