0

私はpythonとTwythonが初めてで、ユーザーのすべてのフォロワーのリストを取得したいので、このコードを使用しています

twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
followers = twitter.get_followers_list(screen_name = "abcd")

for theList in followers:
    id = theList[ 0 ]
    print id

しかし、私はエラーが発生しています。これは、最後の 3 行が原因である可能性があります。

4

1 に答える 1

1

get_followers_list は json オブジェクトを返します。フィールドの名前を使用して json オブジェクトからフィールドを取得できます。以下は同じ例です。

next_cursor = -1

while(next_cursor):

検索 = twitter.get_followers_list(screen_name='abcd',cursor=next_cursor)

for result in search['users']:
    time_zone =result['time_zone'] if result['time_zone'] != None else "N/A"
    print result["name"].encode('utf-8')+ ' '+time_zone.encode('utf-8')
next_cursor = search["next_cursor"]
于 2013-10-19T04:54:42.210 に答える