2011-05-10 53 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)