需要從文本鍵獲取數據一直在嘗試它不起作用并給出錯誤: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貢獻1820條經驗 獲得超2個贊
resp['choices']是一個列表,所以你需要整數索引來訪問它的元素:
resp = json.loads(str(result))
resp['choices'][0]['text']
添加回答
舉報
0/150
提交
取消