如何使用python循环遍历Google云存储上的子目录中的所有文件名?

2024-05-09 18:20:02 发布

您现在位置:Python中文网/ 问答频道 /正文

假设我在Google云存储上有一个bucket/子目录,这个bucket的地址是:

gs://test-monkeys-example/training_data/cats

在这个cats子目录中,我有一堆cats的图片,它们都是jpg。在python中,我如何遍历cats子目录并打印出其中所有文件的名称?

类似于:

for x in directory('gs://test-monkeys-example/training_data/cats'):
    print(x)

显然目录('gs://test monkeys example/training_data/cats')不是怎么做的,只是伪代码-我怎么做?!


Tags: 文件test名称gsfordatabucketexample