属性错误:“响应”对象没有属性“数据”;
我正在玩 tweepy 但我不确定这就是问题所在,也许是我的编辑器(Atom)?
我已经使用以下方法成功从 api 中提取了数据:
users = client.get_users_followers(id=id)
然后我希望打印数据。
for user in users.data:
print(user.username)
我收到错误 AttributeError: 'Response' object has no attribute 'data'
如果我这样做
for user in users:
print(user)
,它会打印所有数据,这样我就知道 api 正在工作,但不允许我将其仅与用户名隔离。
数据输出看起来像这样(小片段),我只想打印用户名
b'{"data":[{"id":"737596418123124736","name":"Gary Surridge","username":"LordSurridge “}
有什么想法吗?
I'm playing around with tweepy but I'm not sure that's the issue, maybe with my editor (Atom)?
I've successfully pulled data from the api using:
users = client.get_users_followers(id=id)
I then wish to print the data.
for user in users.data:
print(user.username)
I get the error AttributeError: 'Response' object has no attribute 'data'
If I do
for user in users:
print(user)
It prints all the data so I know the api is working, but doesn't allow me to isolate it to just the usernames.
The data output looks like this (small snippet) and I just want to print the username
b'{"data":[{"id":"737596418123124736","name":"Gary Surridge","username":"LordSurridge"}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除“b”字符Python 3 中字符串文字前面
Remove 'b' character do in front of a string literal in Python 3