- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是 Python 和 Google Cloud Storage 新手。我正在编写一个 python 脚本,以使用 Google Cloud Python 客户端库从 Google Cloud Storage 存储桶中获取文件列表,并且 Bucket 类中的 list_blobs() 函数没有按预期工作。
https://googlecloudplatform.github.io/google-cloud-python/stable/storage-buckets.html
这是我的python代码:
from google.cloud import storage
from google.cloud.storage import Blob
client = storage.Client.from_service_account_json(service_account_json_key_path, project_id)
bucket = client.get_bucket(bucket_id)
print(bucket.list_blobs())
如果我对文档的理解正确,print(bucket.list_blobs()) 应该打印如下内容:['testfile.txt', 'testfile2.txt']。
但是,我的脚本打印了这个:“0x7fdfdbcac590 处的 google.cloud.storage.bucket._BlobIterator 对象”
delete_blob() 文档中的示例代码与我的相同。 https://googlecloudplatform.github.io/google-cloud-python/stable/storage-buckets.html
我不确定我在这里做错了什么。任何指针/示例/答案将不胜感激。谢谢!
最佳答案
列表函数示例:
def list_blobs(bucket_name):
"""Lists all the blobs in the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blobs = bucket.list_blobs()
for blob in blobs:
print(blob.name)
关于python - 谷歌云存储 Python list_blobs() 不打印对象列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39784244/
我以为它只返回叶子 blob 文件,之前就是这种情况,但现在它突然也返回虚拟目录,是我有错误的印象还是一夜之间发生了什么变化? 假设我有以下结构 container/dir0/dir1/blob1.j
我只想在 GCS 上获得假文件夹结构的第一级。 如果我运行例如: gsutil ls 'gs://gcp-public-data-sentinel-2/tiles/' 我得到一个这样的列表: gs:/
您好,我正在使用 Azure 逻辑应用程序列出 Blob,然后循环列表并删除早于指定日期的 Blob。我使用 Azure Portal Logic App Designer 来构建它。这工作正常。我想
我是 Python 和 Google Cloud Storage 新手。我正在编写一个 python 脚本,以使用 Google Cloud Python 客户端库从 Google Cloud Sto
我有一个非常简单的 python 函数: def list_blobs(bucket, project) storage_client = storage.Client(project=pro
我正在使用 Google Cloud Storage Python API 收集 Cloud Storage 中特定子目录中包含的文件列表。 bucket.list_blobs(prefix='abc
我正在使用 Google Cloud Storage Python API 收集 Cloud Storage 中特定子目录中包含的文件列表。 bucket.list_blobs(prefix='abc
从 ContainerClient.list_blobs() 返回的 blob 数量如何方法可以限制吗? azure Blob service RESP API docs提到了 maxresults
我在使用 Python Azure SDK 时遇到问题,并且在 Stack Overflow 和 Msdn 论坛上都没有找到任何内容。 我想使用 Azure SDK list_blobs() 获取 B
我想使用 Client Library for Python 获取 Google Cloud Storage 存储桶中所有 blob 的列表. 根据documentation我应该使用 list_bl
我是一名优秀的程序员,十分优秀!