3
我有以下簡單的片斷這之前工作得很好,但現在的心不是:Tweepy錯誤 - 類型錯誤:__init __()失蹤1個人需要的位置參數:「聽衆」
import sys
import tweepy
# Consumer keys and access tokens, used for OAuth
consumer_key=""
consumer_secret=""
access_key = ""
access_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
class CustomStreamListener(tweepy.StreamListener):
def on_status(self, status):
print >>status.text
def on_error(self, status_code):
print >>sys.stderr, 'Encountered error with status code:', status_code
return True # Don't kill the stream
def on_timeout(self):
print >>sys.stderr, 'Timeout...'
return True # Don't kill the stream
sapi = tweepy.streaming.Stream(auth, CustomStreamListener())
sapi.filter(locations=[-180,-90,180,90])
此代碼應打印來自全國各地的鳴叫世界。但是,我收到錯誤:
sapi = tweepy.streaming.Stream(auth, CustomStreamListener())
TypeError: __init__() missing 1 required positional argument: 'listener'
請大家幫忙,謝謝!
編輯:
因此,我改變
sapi = tweepy.streaming.Stream(auth, CustomStreamListener())
到:
sapi = tweepy.streaming.Stream(auth, listener=CustomStreamListener())
,現在我得到以下(類似的)錯誤:
sapi = tweepy.streaming.Stream(auth, listener=CustomStreamListener())
TypeError: __init__() missing 1 required positional argument: 'password'
也許這將讓某人洞察什麼是在這裏,因爲我不知道。
感謝
請添加完整跟蹤 – alko
即完整跟蹤 – user1452494
沒有文件,沒有調用堆棧? – alko