data: {\"id\":123,\"channel\":\"private_A25BHd\",\"text\":{\"content\":\"{\\"m\\":\\"event\\",\\"p\\":{\\"id\\":123123123,\\"aid\\":125123123,\\"sym\\":\\"BITMEX:XBTUSD\\",\\"res\\":\\"1\\",\\"desc\\":\\"test message on line1\\ntest message on line2\\",\\"snd\\":false,\\"snd_file\\":\\"alert\/fired\\",\\"snd_duration\\":0.0,\\"popup\\":true,\\"fire_time\\":123123,\\"bar_time\\":123123,\\"cross_int\\":true}}\",\"channel\":\"alert\"}}
不幸的是,它以字符串的形式出现,不过如果可能的话,我想把它改成dict。你知道吗
您可以使用函数
json.loads()
,通过导入json
库将字符串解析为JSON对象(Python字典)。你知道吗代码:
输出:
如果只想打印任何特定值,可以使用
它打印
id
值,即123
在python中使用json库
相关问题 更多 >
编程相关推荐