1

我有两个用户列表,早期采用者和追随者。我想创建一对用户

(早期采用者,追随者)。例如:

#in 
early_adopters = [1, 2, 3]

#out
follower_list = [(1,a),(1,b),(1,c),(2,a),(2,e),(3,f)]

在下面的代码中,我可以检索关注者列表,但这并没有指定谁关注谁。

follower_list = []
early_adopters = [1, 2, 3]

for usr in ea:
  for user in tweepy.Cursor(api.followers, user_id = usr).items():
    if user.id not in ea:
      follower_list.append(user.id)
4

1 回答 1

1

你非常接近:

follower_list = []
early_adopters = [1, 2, 3]

for usr in early_adopters:
  for user in tweepy.Cursor(api.followers, user_id = usr).items():
    if user.id not in early_adopters:
      follower_list.append((usr, user.id))

(early_adopter, follower)这会在followers_list 中存储一个元组。

于 2020-08-02T17:40:15.953 回答