PRAW:你如何获得你的提交 link?

PRAW: How do you get your submission link?

def self_post():
for i in sub_reddit:

    reddit.subreddit(i).submit(post_title, url=post_body)
    print("posted on " + i)
    print(submission.permalink)
    submission.reply('This is a test reply')
    print(submission.permalink)

post 线程工作正常,但我正在尝试获取 post URL,然后回复该提交,我该怎么做?

submit方法returns已创建的提交。所以你可以通过做

来保存它
submission = reddit.subreddit(subreddit).submit(post_title, selftext=post_body)

您还可以通过保存调用该方法的结果来获取通过 reply 创建的评论:

comment = submission.reply('This is a test reply')

那么你的函数就变成了:

def self_post(post_title, post_body):
    for subreddit in sub_reddit:
        submission = reddit.subreddit(subreddit).submit(post_title, url=post_body)
        print("posted on " + subreddit)
        print(submission.permalink)
        reply = submission.reply('This is a test reply')
        print(reply.permalink)