📜  Python Tweepy – 获取用户的描述

📅  最后修改于: 2022-05-13 01:55:06.662000             🧑  作者: Mango

Python Tweepy – 获取用户的描述

在本文中,我们将了解如何获取用户的描述。的描述描述了一个用户帐户。 description 属性是可选的,并且可以为 Nullable。

识别 GUI 中的描述:

在上述个人资料中,描述是:您获得编码涅槃的一站式目的地……

示例 1:考虑以下配置文件:

我们将使用用户 ID 来获取用户。上述配置文件的用户 ID 是 57741058。

# import the module
import tweepy
  
# assign the values accordingly
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
  
# authorization of consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  
# set access to user's access key and access secret 
auth.set_access_token(access_token, access_token_secret)
  
# calling the api 
api = tweepy.API(auth)
  
# the ID of the user
id = 57741058
  
# fetching the user
user = api.get_user(id)
  
# fetching the description
description = user.description
  
print("The description of the user is : " + description)

输出 :

The description of the user is : Your one-stop destination to attain Coding Nirvana...

示例 2:考虑以下配置文件:

我们将使用屏幕名称来获取用户。上述个人资料的网名是 PracticeGfG。

# the screen name of the user
screen_name = "PracticeGfG"
  
# fetching the user
user = api.get_user(screen_name)
  
# fetching the description
description = user.description
  
print("The description of the user is : " + description)

输出 :

The description of the user is : Platform to practice programming problems. Solve 
company interview questions and improve your coding intellect!