以下是相关的JSON数据:
{
"result_index": 0,
"results": [
{
"alternatives": [
{
"confidence": 0.994,
"transcript": "thunderstorms could produce large hail isolated tornadoes and heavy rain "
}
],
"final": true
}
]
}
下面是我如何尝试访问它
parsed = json.loads(data)
print(parsed['results']['alternatives']['transcript'])
这将导致以下错误:
TypeError: list indices must be integers or slices, not str
似乎results只是一个数组,其中只有一个条目是字符串,我对如何访问其中的单个元素有点困惑
你的
results
和alternatives
不是对象;但是物体的阵列相关问题 更多 >
编程相关推荐