用户 ID 到用户名 tweepy [英] User ID to Username tweepy

查看:58
本文介绍了用户 ID 到用户名 tweepy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何从 tweepy 上的一个 ID 中获取一个用户名?我到处找都找不到.

Can someone please tell me how to get one username from one id on tweepy? I have looked everywhere and can't find anything.

推荐答案

如果您只有一个 user_id 值,您需要使用 get_user(user_id) 方法.返回的 User 对象将包含 screen_name 下的用户名.

If you just have a user_id value you need to call the twitter API with the get_user(user_id) method. The returned User object will contain the username under screen_name.

# steps not shown where you set up api
u = api.get_user(783214)
print u.screen_name

如果您已经拥有来自另一个 API 调用的 User 对象,只需查找 screen_name.

If you already have the User object from another API call just look for the screen_name.

这篇关于用户 ID 到用户名 tweepy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆