0

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?

1 Answers1

0

Remove 'b' character do in front of a string literal in Python 3

utf = user.encode('utf-8')
print(utf[0].username)
  • Hi. Thanks for this but it hasn't solved the issue. I'm also not sure why this isn't an issue for other people from when I've googled twitter api – Wagsforever Feb 23 '22 at 16:28