python 加载json文件显示在文本框中,在Python中加载Json文件和格式化数据

我有一个来自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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值