📌  相关文章
📜  Python PRAW - 检查 redditor 是否是 Reddit 的员工

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

Python PRAW - 检查 redditor 是否是 Reddit 的员工

在 Reddit 中,redditor 是给予用户的术语。在这里,我们将看到如何检查 redditor 是否是 Reddit 的员工。我们将使用Redditor类的is_employee属性来检查 redditor 是否是 Reddit 的员工。

示例 1:考虑以下 redditor:

redditor的用户名是:spez,spez是reddit的创始人,所以他是Reddit的员工。

# importing the module
import praw
  
# initialize with appropriate values
client_id = ""
client_secret = ""
username = ""
password = ""
user_agent = ""
  
# creating an authorized reddit instance
reddit = praw.Reddit(client_id = client_id, 
                     client_secret = client_secret, 
                     username = username, 
                     password = password,
                     user_agent = user_agent) 
  
# the name of the redditor
redditor_name = "spez"
  
# instantiating the Redditor class
redditor = reddit.redditor(redditor_name)
  
print("Is " + redditor_name + " an employee of Reddit? : " +
      str(redditor.is_employee))

输出 :

Is spez an employee of Reddit? : True

示例 2:考虑以下 redditor:

redditor 的用户名是:AutoModerator

# importing the module
import praw
  
# initialize with appropriate values
client_id = ""
client_secret = ""
username = ""
password = ""
user_agent = ""
  
# creating an authorized reddit instance
reddit = praw.Reddit(client_id = client_id, 
                     client_secret = client_secret, 
                     username = username, 
                     password = password,
                     user_agent = user_agent) 
  
# the name of the redditor
redditor_name = "AutoModerator"
  
# instantiating the Redditor class
redditor = reddit.redditor(redditor_name)
  
print("Is " + redditor_name + " an employee of Reddit? : " +
      str(redditor.is_employee))

输出 :

Is AutoModerator an employee of Reddit? : False