TypeError:无法连接“str”和“Response”对象

2024-09-29 22:19:27 发布

您现在位置:Python中文网/ 问答频道 /正文

(忽略g.text和p.content返回“您无权查看此内容”的插头.dj)我知道错误了

Traceback (most recent call last):
  File "plugling.py", line 20, in <module>
    r.send('{"a":"auth","p":"'+g+'","t":'+t+'}')
TypeError: cannot concatenate 'str' and 'Response' objects

运行此代码时:

^{pr2}$

它也不喜欢我用%s作为变量。我不知道我做错了什么。提前谢谢,如果我没有解释清楚,请告诉我。在


Tags: textpy内容most错误djcontentcall
1条回答
网友
1楼 · 发布于 2024-09-29 22:19:27

您正在尝试连接Response对象:

g = requests.get(token)
# ...
r.send('{"a":"auth","p":"'+g+'","t":'+t+'}')

g是响应对象。你想得到文本值

^{pr2}$

如果您试图将JSON数据发送到^{} module,那么您可能需要查看^{} module

r.send(json.dumps({'a': 'auth', 'p': g.text, 't': t}))

相关问题 更多 >

    热门问题