En Reddit, un redditor es el término dado a un usuario. Reddit nos brinda la funcionalidad de agregar un redditor como amigo del usuario autenticado. También podemos eliminar a un amigo. Aquí veremos cómo dejar de ser amigo de un redditor. Usaremos el unfriend()
método de la Redditor
clase para eliminar a un redditor.
no amigo()
Sintaxis: Redditor.unfriend()
Parámetro: Ninguno
Devoluciones: Nada
Ejemplo 1: Considere el siguiente redditor:
El nombre de usuario del redditor es: spez
# 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) # before using the unfriend() method print("Are the authenticated user and " + redditor.name + " friends? : " + str(redditor.is_friend)) # unfriending the redditor redditor.unfriend() # after using the unfriend() method print("Are the authenticated user and " + redditor.name + " friends? : " + str(redditor.is_friend))
Producción :
Are the authenticated user and spez friends? : True Are the authenticated user and spez friends? : False
Ejemplo 2: Considere el siguiente redditor:
El nombre de usuario del redditor es: AutoModerador
# 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) # before using the unfriend() method print("Are the authenticated user and " + redditor.name + " friends? : " + str(redditor.is_friend)) # unfriending the redditor redditor.unfriend() # after using the unfriend() method print("Are the authenticated user and " + redditor.name + " friends? : " + str(redditor.is_friend))
Producción :
Are the authenticated user and AutoModerator friends? : True Are the authenticated user and AutoModerator friends? : False