需要從文本鍵獲取數(shù)據(jù)一直在嘗試它不起作用并給出錯誤:list indices must be integers or slice, not strresp = json.loads(str(result)) resp['choices']['text] JSON:{ "choices": [ { "finason": "stop", "index": 0, "logprobs": null, "text": "hihihiii" } ], "created": 1595021770, "id": "cmp pvu4OUC5Qbh4C", "model": " 2020-05-03", "object": "tex tion"}
1 回答

DIEA
TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超3個贊
resp['choices']是一個列表,所以你需要整數(shù)索引來訪問它的元素:
resp = json.loads(str(result))
resp['choices'][0]['text']
添加回答
舉報(bào)
0/150
提交
取消