下面是代码
connection_string='DefaultEndpointsProtocol=https;AccountName=example;AccountKey='
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
container_client = blob_service_client.get_container_client("example123")
files = container_client.list_blobs(name_starts_with="ABC")
print(files)
for blob in files:
print("\t" + blob.name)
blobr = blob.download_blob().readall()
print(blobr)
tmp_data = blobr.read().decode('utf-8')
print(tmp.data)
错误:
AttributeError: 'BlobProperties' object has no attribute 'download_blob'
请指导如何从存储容器读取blob并加载json或进行进一步处理
这是因为
list_blobs
方法只返回blob属性,而不返回blob对象。所以不能通过blob属性调用download_blob
方法您应该在
for
语句中更改代码,如下所示:相关问题 更多 >
编程相关推荐