![](/img/trans.png)
[英]IBM Watson Speech-to-Text Python, 'DetailedResponse' object has no attribute 'getResult'
[英]Watson Python SDK: 'DetailedResponse' object is not subscriptable
當我將 Watson Assistant 示例代碼用於 Python 時,它在 python 3.6.5 上運行良好。
但我收到錯誤:
TypeError: 'DetailedResponse' object is not subscriptable
當我嘗試在 python 3.6.6 中執行代碼時,它失敗的命令是:
if response['output']['text']:
print(response['output']['text'][0])
如果我打印對象響應的類型,我會得到:
任何指針將不勝感激!
好的,找到答案了,希望能幫到其他人:
現有代碼:
if response['output']['text']:
print(response['output']['text'][0])
修改后的代碼:
if response.result['output']['text']:
print(response.result['output']['text'][0])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.