首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AttributeError:'str‘对象没有属性'get’随机填充api python

AttributeError:'str‘对象没有属性'get’随机填充api python
EN

Stack Overflow用户
提问于 2022-04-18 05:20:11
回答 1查看 63关注 0票数 0

我试图使用随机物 api制作一个AI聊天机器人,每当我尝试创建一个聊天机器人时,我总是会得到这个错误(我使用replit.com来托管):

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "main.py", line 5, in <module>
    response = client.get_ai_response("Hi there!")
  File "/home/runner/ChatBot/venv/lib/python3.8/site-packages/randomstuff/client.py", line 254, in get_ai_response
    message=response[0].get('response'),
AttributeError: 'str' object has no attribute 'get'

守则如下:

代码语言:javascript
运行
复制
    import randomstuff

    client = randomstuff.Client(api_key="xxx")

    response = client.get_ai_response("Hi there!")
    print(response.message)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-18 05:26:38

我相信这个API已被否决:

嘿,我们反对我们的旧版本,现在我们只能通过RapidApi操作。如需更多信息,请访问https://api.pgamerx.com/new

您应该切换到新版本,因为旧版本不再起作用了。

顺便说一句,这也是您获得错误的原因,因为对旧API的任何调用都会返回上面的字符串,而该字符串显然没有get()函数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71907838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档