📌  相关文章
📜  Python PRAW - 检查评论是否已在 Reddit 中编辑

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

Python PRAW - 检查评论是否已在 Reddit 中编辑

在 Reddit 中,我们可以对任何提交发表评论,也可以对评论发表评论以创建评论线程。评论可以在发布后稍后进行编辑。在这里,我们将看到如何使用 PRAW 检查评论是否已被编辑。我们将使用Comment类的edited属性来检查评论是否已被编辑。

示例 1:考虑以下评论:

评论的ID是:fvib7aw

# 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 ID of the comment
comment_id = "fvib7aw"
  
# instantiating the Comment class
comment = reddit.comment(comment_id)
  
# fetching the edited attribute
edited = comment.edited 
  
if edited == True:
    print("The comment has been edited.")
elif edited == False:
    print("The comment has not been edited.")

输出 :

The comment has not been edited.

示例 2:考虑以下评论:

评论的ID是:fv9qvgo

# 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 ID of the comment
comment_id = "fv9qvgo"
  
# instantiating the Comment class
comment = reddit.comment(comment_id)
  
# fetching the edited attribute
edited = comment.edited 
  
if edited == True:
    print("The comment has been edited.")
elif edited == False:
    print("The comment has not been edited.")

输出 :

The comment has not been edited.