Python Tweepy – Getting the ID of a user
In this article we will see how we can get the ID of a user. ID is the unique identification marker of the twitter account. ID is given to the user by Twitter, the user can not select or change their own ID.
In order to get the ID we have to do the following :
- Identify the user screen name of the profile.
- Get the User object of the profile using the
get_user()method and the user name.
- From this object, fetch the id or id_str attribute present in it.
Example 1: Consider the following profile :
The screen name of the above mentioned profile is geeksforgeeks.
The ID of the user is : 57741058
Example 2: Consider the following profile :
The screen name of the above mentioned profile is PracticeGfG.
The ID of the user is : 4802800777
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course