gpt4 book ai didi

python - 检查 python azure 中是否存在 blob

转载 作者:行者123 更新时间:2023-12-04 02:31:34 25 4
gpt4 key购买 nike

自从 azure-storage-blob 更新后,blockblobservice 已贬值

如何检查 blob 是否存在?

此答案不适用于新版本的 azure-storage-blob Faster Azure blob name search with python?

我在 GitHub 上发现了这个问题: https://github.com/Azure/azure-sdk-for-python/issues/12744

最佳答案

版本12.5.0于 2020 年 9 月 10 日发布的版本现在在新 SDK 中具有 exists 方法。

例如,

同步:

from azure.storage.blob import BlobClient

blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="mycontainer", blob_name="myblob")
exists = blob.exists()
print(exists)

异步:

import asyncio

async def check():
from azure.storage.blob.aio import BlobClient
blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="mycontainer", blob_name="myblob")
async with blob:
exists = await blob.exists()
print(exists)

关于python - 检查 python azure 中是否存在 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63888136/

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