Azure Blob存储未列出Blob

时间:2019-03-26 20:08:13

标签: azure blob azure-storage-blobs

我无法列出特定容器中的斑点

我正在使用Python的正式代码列出:

from azure.storage.blob import BlockBlobService

account_name = 'xxxx'
account_key = 'xxxx'
container_name = 'yyyyyy'

block_blob_service = BlockBlobService(account_name=account_name, 
account_key=account_key) 

print("\nList blobs in the container")
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
    print("\t Blob name: " + blob.name)

我收到了错误:

raise AzureException(ex.args[0])

AzureException: can only concatenate str (not "tuple") to str

与Azure存储相关的软件包的安装版本为:

azure-mgmt-storage                    2.0.0
azure-storage-blob                    1.4.0
azure-storage-common                  1.4.0

1 个答案:

答案 0 :(得分:0)

我尝试用我的帐户运行与您相同的代码,它运行正常,没有任何问题。然后,根据错误信息,我还尝试重现它,如下所示。

测试1.当我尝试在Python 3.7中运行代码'123'+('A','B')时,遇到了与下图类似的问题。

enter image description here

测试2。在Python 3.6中运行相同的代码时,错误信息不同。

enter image description here

测试3。在Python 2中(仅在WSL上),相同的问题类似于Python 3.7

enter image description here

因此,我想您使用的是Python 3.7或2运行代码,而问题是由使用+符号将字符串与元组的其他位置连接在一起引起的。请尝试仔细检查或更新您的帖子,以获取有关调试信息的更多详细信息,其中包括行号及其代码以帮助进行分析。

相关问题