【问题标题】:Tweepy does not let me run api.get_user with a list of users and also not on a single personTweepy 不允许我使用用户列表运行 api.get_user,也不允许在一个人上运行
【发布时间】:2021-12-30 05:10:31
【问题描述】:
api = tweepy.API(auth)
userID_list = ["elonmusk", "BarackObama"]

for userxyz in userID_list:

    user_info = api.get_user(userxyz)
    name = user_info.name
    description = user_info.description
    location = user_info.name.location
    followers_count = user_info.followers_count
    friends_count = user_info.friends_count

写入此错误:

Traceback (most recent call last):
  File "C:/Users/wilsi/Desktop/test 123.py", line 36, in <module>
    user_info = api.get_user(userxyz)
  File "C:\Users\wilsi\Desktop\venv\lib\site-packages\tweepy\api.py", line 46, in wrapper
    return method(*args, **kwargs)
TypeError: get_user() takes 1 positional argument but 2 were given

【问题讨论】:

    标签: python media data-mining tweepy social


    【解决方案1】:

    API.get_user 仅接受单个用户作为 user_idscreen_name 关键字参数。

    另见the FAQ section in Tweepy's documentation about this

    有关代码块的使用,请参阅https://stackoverflow.com/editing-help

    【讨论】:

    • 我需要如何调整代码才能正常工作?`
    • 您可以将userxyz 作为screen_name 关键字参数传递。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    相关资源
    最近更新 更多