我是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())
Run Code Online (Sandbox Code Playgroud)
如果我正确理解了文档,则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
我不确定我在做什么错。任何指针/示例/答案将不胜感激。谢谢!
python google-app-engine google-cloud-storage google-cloud-platform google-cloud-python
python ×1