本文档here说“请注意,如果您不使用默认存储桶,则需要其他方式来提供存储桶名称。”如何提供非默认存储桶?
我知道如何使用 gfile 使用“gs://<bucket_name>//file
语法读取任何存储桶,但这是一个不同的 api。
最佳答案
摘自 open
的文档方法:
https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions#open
Arguments
block 引用>filename (REQUIRED) The file to open, in the format /bucket/object.
您需要提供给 api 的格式是
"/<bucket_name>/<file>"
例如:
"/my_bucket/lyrics/southamerica/list5.txt"
这是对
open
的 GitHub 引用方法 https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/master/python/src/cloudstorage/cloudstorage_api.py#L47-L54
关于python - 如何在Python中从谷歌云存储中的非默认存储桶读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51412846/