Google cloud platform 是否可以像在终端中使用'ls'命令一样查询谷歌云存储?

Google cloud platform 是否可以像在终端中使用'ls'命令一样查询谷歌云存储?,google-cloud-platform,google-cloud-storage,google-python-api,Google Cloud Platform,Google Cloud Storage,Google Python Api,我使用python库查询Google云存储,并使用命名层次结构组织存储中的信息。例如: my_bucket/simulations/version_1/data... my_bucket/simulations/version_2/data... my_bucket/simulations/version_3/data... my_bucket/other_data/more_data... 我的问题是:是否可以使用list\u blobs或其他方法查询只包含“simulations”目录中的

我使用python库查询Google云存储,并使用命名层次结构组织存储中的信息。例如:

my_bucket/simulations/version_1/data...
my_bucket/simulations/version_2/data...
my_bucket/simulations/version_3/data...
my_bucket/other_data/more_data...
我的问题是:是否可以使用
list\u blobs
或其他方法查询只包含“simulations”目录中的版本的列表,而不包含simulations下面的所有blobs

作为参考,这将以分页方式返回所有BLOB:

cursor = bucket.list_blobs(prefix='simulations')

我使用了
list\u blobs
方法的
前缀
分隔符
参数,该代码有效:

从google.cloud导入存储
def ls(桶名称、前缀、分隔符):
storage\u client=storage.client()
bucket=存储\客户端。获取\ bucket(bucket\名称)
游标=bucket.list_blob(前缀=前缀,分隔符=分隔符)
对于光标中的blob:
通过
对于cursor.prefixes中的前缀:
打印前缀
ls(你的名字,'模拟/','模拟/')
输出:

simulations/version-1/
simulations/version-2/
simulations/version-3/
请注意,这将仅显示
simulations/
目录中的目录名称,文件将被忽略