擅长:python、mysql、java
<p>这对我有效:</p>
<pre><code>client = storage.Client()
BUCKET_NAME = 'DEMO_BUCKET'
bucket = client.get_bucket(BUCKET_NAME)
blobs = bucket.list_blobs()
for blob in blobs:
print(blob.name)
</code></pre>
<p>list_blobs()方法将返回一个迭代器,用于查找bucket中的blob。
现在可以遍历blob并访问bucket中的每个对象。在本例中,我只是打印出对象的名称。</p>
<p>这些文档帮助我:</p>
<ul>
<li><p><a href="https://googleapis.github.io/google-cloud-python/latest/storage/blobs.html" rel="noreferrer">https://googleapis.github.io/google-cloud-python/latest/storage/blobs.html</a></p></li>
<li><p><a href="https://googleapis.github.io/google-cloud-python/latest/_modules/google/cloud/storage/client.html#Client.bucket" rel="noreferrer">https://googleapis.github.io/google-cloud-python/latest/_modules/google/cloud/storage/client.html#Client.bucket</a></p></li>
</ul>
<p>我希望我能帮忙!</p>