gpt4 book ai didi

python - 适用于 Python 的 Azure SDK : How to limit results in list_blobs()?

转载 作者:行者123 更新时间:2023-12-04 09:42:06 26 4
gpt4 key购买 nike

ContainerClient.list_blobs() 返回的 blob 数量如何方法可以限制吗?

azure Blob service RESP API docs提到了 maxresults 参数,但 list_blobs(maxresults=123) 似乎不支持它。

最佳答案

结合使用 itertools.isliceresults_per_page 参数(转换为 REST maxresults 参数)即可实现此目的:

import itertools

service: BlobServiceClient = BlobServiceClient.from_connection_string(cstr)
cc = service.get_container_client("foo")

n = 42
for b in itertools.islice(cc.list_blobs(results_per_page=n), n):
print(b.name)

关于python - 适用于 Python 的 Azure SDK : How to limit results in list_blobs()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62279656/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com