Python 2.7:Imgur API 并从 post 获得明文评论?

Python 2.7: Imgur API and getting clear text comments from a post?

client = ImgurClient(client_id, client_secret, access_token, refresh_token)
for item in client.gallery_item_comments("c1SN8", sort='best'):
    print item

这是我当前的代码。我想做的是(希望)return 来自该函数的评论 ID 列表。它不这样做,而是输出这个。

<imgurpython.imgur.models.comment.Comment object at 0x03D8EFB0>
...

我想问的是,是否有来自 Imgur api 的函数组合来获取评论 ID 列表? API

在上面的代码中,item 是一个 Comment 对象,表示评论本身。因为它没有定义如何打印对象的方式,所以您会看到 imgurpython.imgur.models.comment.Comment 告诉您对象类型,而 0x03D8EFB0 表示对象在内存中的地址。别担心,这正是您要找的评论。

查看 Comment 的 Imgur API documentation,可以看到 Comment 具有以下属性:idimage_idcommentauthor , author_id, on_album, album_cover, ups, downs, points, datetime, parent_id, deletedvotechildren

您可以通过在 for 循环中访问 item.<property> 来访问每个 属性。例如,如果你想打印所有的 ids 你可以这样做:

client = ImgurClient(client_id, client_secret, access_token,  refresh_token)
for item in client.gallery_item_comments("c1SN8", sort='best'):
    print item.id