Python Tweepy – Getting the name of a user
In this article we will see how we can get the name of a user. Name is the display name of the twitter account. It is the name that users choose to identify themselves on the network. Many users choose to either use their real name as the basis for their display name. Unlike screen names, the names need not be unique. Moreover the names can be in any language script, the screen name can only be in English(Latin). Names can also have spaces and special characters in them.
Identifying the name in the GUI :
In the above mentioned profile, GeeksforGeeks is the name of the profile.
In order to get the name we have to do the following :
- Identify the user ID or screen name of the profile.
- Get the User object of the profile using the
get_user()method with the user ID or the screen name.
- From this object, fetch the name attribute present in it.
Example 1: Consider the following profile :
We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.
The name of the user is : GeeksforGeeks
Example 2: Consider the following profile :
We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.
The name of the user is : Practice GfG