我有一个来自stackoverflow的Json文件,如下所示:
第一行表示Json对象的个数,在这里它是22
{"topic":"electronics","question":"What is the effective differencial effective of this circuit","excerpt":"I'm trying to work out, in general terms, the effective capacitance of this circuit (see diagram: http://i.stack.imgur.com/BS85b.png). \n\nWhat is the effective capacitance of this circuit and will the ...\r\n "}
{"topic":"electronics","question":"Heat sensor with fan cooling","excerpt":"Can I know which component senses heat or acts as heat sensor in the following circuit?\nIn the given diagram, it is said that the 4148 diode acts as the sensor. But basically it is a zener diode and ...\r\n "}
Json文件的内容如下所示
^{pr2}$
我正在学习ML,我想把数据解析成下面的格式data[i][0] = contains question
data[i][1] = contains string
data[i][2] = topic
这样我就可以训练我的分类器了。我是python新手,或者有更好的技术来表示数据,因为我将其用作训练数据
我写了这段代码,但不起作用给我错误:with open("ml.json") as t:
data = json.load(t)
print(data)