Boto (Python)-反转的遗愿清单
有谁知道如何获得反向遗愿清单。
bucketList = self.bucket.list(PREFIX)
bucketList.reverse()
不起作用。
谢谢, 罗恩.
Does anyone know how to get reversed bucket list.
bucketList = self.bucket.list(PREFIX)
bucketList.reverse()
does not work.
Thanks,
Ron.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法执行bucket.list() 的相反操作的原因是该方法实际上返回一个生成器而不是实际的列表。这更加高效,并且还允许 boto 在幕后处理所有结果分页。
如果你真的想反转它,你可以收集列表中的所有元素,然后反转它:
但如果桶中有很多对象,这将非常低效。
The reason that you can't do a reverse of bucket.list() is because that method actually returns a generator rather than the actual list. This is much more efficient and also allows boto to handle all of the paging of results behind the scenes.
If you really want to reverse it you could collect all of the elements in a list and then reverse that:
but if there are a lot of objects in the bucket this will be very inefficient.