如何通过tweepy从用户ID号中删除明文用户名?
以下是我正在使用的正确代码:
ids = []
userid = "someOne"
for page in tweepy.Cursor(api.followers_ids, screen_name=userid).pages():
ids.extend(page)
time.sleep(60)
print len(ids), "following have been gathered from", userid
users = api.lookup_users(user_ids=ids)#ieterates through the list of users and prints them
for u in users:
print u.screen_name
我评论的最后一行是给我一个问题。请指教。谢谢大家!
答案 0 :(得分:9)
您正在迭代ids
,而i
已包含ids
的元素。尝试将i
传递给lookup_users
:
for i in ids:
print screen_name(api.lookup_users(i))
# print screen_name(api.lookup_users(ids[i]))
更新,请尝试以下方式:
users = api.lookup_users(user_ids=ids)
for u in users:
print u.screen_name