1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Twitterのリストの操作

Last updated at Posted at 2014-01-07

##リストの参照

#ユーザーのリストを取得し、登録されているユーザー数を出力

#tはtwitterクラスインスタンス
hoge = t.lists.list(user_id='user_id')

for h in hoge:
    print(h['name'] + ':' + h['id_str'])
    cursor = '-1' 
    count = 0
    while cursor != '0':
        #cursor=-1 the first "page."
        tl = t.lists.members(list_id=h['id_str'],cursor=cursor)
        count += len(tl['users'])
        cursor = tl['next_cursor_str'] #次ページなければ0が入力されている
    print(count)

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?