如何在google drive中创建子目录

问题描述 投票:1回答:1

我正在遵循一个教程,该教程要求我在我的一个文件夹中创建一个子目录。在教程中,它展示了如何在文件是本地的情况下做到这一点;然而,我的文件是在Google Drive上。我希望能够使目录看起来像下面这样。

My Drive
  └── Colab Notebooks
        └── Web scraper
              └── dataset_dogs_vs_cats
                      ├── test
                      │   ├── cats
                      │   └── dogs
                      └── train

我只想为 "测试 "下的两个子目录创建文件夹。如果文件是本地的,下面的代码就是你要做的。

# create directories
dataset_home = 'dataset_dogs_vs_cats/'
subdirs = ['train/', 'test/']
for subdir in subdirs:
    # create label subdirectories
    labeldirs = ['dogs/', 'cats/']
    for labldir in labeldirs:
        newdir = dataset_home + subdir + labldir
        makedirs(newdir, exist_ok=True)

我的问题是,我如何修改它,使其与Google Drive兼容?

python file google-drive-api subdirectory
1个回答
1
投票

我知道你想在你的Drive中使用python Drive API创建文件夹,也许你将来会想要填充这些文件夹。在这种情况下,你可以在这里看到的例子如何 创建和填充文件夹. 要设置一个授权脚本,你可以使用 python驱动API快速入门 作为参考。如果您还有一些疑问,请向我提问。

© www.soinside.com 2019 - 2024. All rights reserved.