2011-05-10 62 views
3

我期待关注遵循我的用户,但我没有在Tweepy中关注。我有逻辑,但我的问题是语法。跟随用户在Tweepy

for follower in followers_list: 
     if follower not in friends_list: 
      to_follow.append(follower) 
      print to_follow 
    for follower in to_follow: 
     print follower 
     api.follow(follower) 

有谁知道我应该用什么遵循以人(取代api.follow,不工作的)

+0

create_friendship就是我要找的,但是,它说我需要进行身份验证。任何人都知道我的方式,我可以使用create_friendship与阵列与我的人跟随? – 2011-05-10 03:55:05

+0

一个非相关的建议:你的第一个循环可能被[list comprehenstion](http://docs.python.org/tutorial/datastructures.html#list-comprehensions)取代:'to_follow = [followers_list中的追随者如果追随者不在friends_list中]'。我知道它不能解决你的问题,但我认为它可以是你的代码更pythonic :) – brandizzi 2011-10-10 18:00:41

回答

4

是您的followers_list都是Twitter user.screen_names?如果是这样,这个问题上有一个话题可以帮助你解决问题here

的followers_list应该是一个逗号分隔的列表中,如下所示:

stream = tweepy.Stream(auth, StreamWatcherListener(), timeout=None) 
follow_list = ['1234567890', '2345678901'] 
track_list = None 
stream.filter(follow_list, track_list)