小编Yel*_*our的帖子

使用PyDrive(Python)访问文件夹,子文件夹和子文件

我从PyDrive文档中获得以下代码,允许访问我的Google云端硬盘中的顶级文件夹.我想从中访问所有文件夹,子文件夹和文件.我该怎么做呢(我刚刚开始使用PyDrive)?

#!/usr/bin/python
# -*- coding: utf-8 -*-
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive


gauth = GoogleAuth()
gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication

#Make GoogleDrive instance with Authenticated GoogleAuth instance
drive = GoogleDrive(gauth)

#Google_Drive_Tree = 
# Auto-iterate through all files that matches this query
top_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
for file in top_list:
    print 'title: %s, id: %s' % (file['title'], file['id'])
    print "---------------------------------------------"

#Paginate file lists by specifying number of max results
for …
Run Code Online (Sandbox Code Playgroud)

python metadata python-2.7 google-api-python-client

6
推荐指数
2
解决办法
4406
查看次数