我正在尝试使用python sdk在azure帐户下列出容器 - 为什么我会得到以下内容?
>>> azure.storage.blob.baseblobservice.BaseBlobService(account_name='x', account_key='x').list_containers()
>>> <azure.storage.models.ListGenerator at 0x7f7cf935fa58>
以上是对函数的调用,而不是对函数本身的引用。
答案 0 :(得分:4)
根据source code return return ListGenerator(resp, self._list_containers, (), kwargs)
您可以访问以下内容:
>>>blob_service=azure.storage.blob.baseblobservice.BaseBlobService(account_name='x', account_key='x')
>>>containers = blob_service.list_containers()
>>>for c in containers:
print c.name
答案 1 :(得分:0)
对于python 3和azure
库的最新发行版,您可以执行以下操作:
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name=account_name, account_key=account_key)
containers = block_blob_service.list_containers()
for c in containers:
print(c.name)
答案 2 :(得分:0)
根据 source code
您可以使用以下代码段访问存储帐户中的容器:
from azure.storage.blob import BlockBlobService, PublicAccess
blob_service = BaseBlobService(account_name='<your account name>', account_key='<your account key>')
containers = blob_service.list_containers()
for container in containers:
print ("Container name: {}".format(container.name))
有关设置帐户名和帐户密钥的详细信息,请访问link