Mar*_*haF 0 python google-api python-3.x google-drive-api pydrive
是否可以在 Google 共享云端硬盘中获取文件?PyDrive 能够迭代 MyDrive 中的文件,但不能迭代共享驱动器中的文件。这些文件位于多个文件夹中:
Department -> PDF -> MONTH YEAR -> DATE -> DAILY REPORT.pdf
尝试了代码,但都返回“查看文件夹级别”:
# #Make GoogleDrive instance with Authenticated GoogleAuth instance
# drive = GoogleDrive(gauth)
f = drive.ListFile({"q": "mimeType='application/vnd.google-apps.folder' and trashed=false}).GetList()
for folder in f:
print(folder['title'], folder['id'])
Run Code Online (Sandbox Code Playgroud)
查看文件级别:
# # Auto-iterate through all files that matches this query
# file_list = drive.ListFile({'q': "'{}' in parents and trashed=false".format(folder_id)}).GetList()
# # print(file_list)
# for file1 in file_list:
# print('title: %s, id: %s' % (file1['title'], file1['id']))
Run Code Online (Sandbox Code Playgroud)
发现一个类似的案例。现在可以使用以下代码工作:
# file_list = drive.ListFile({'q':"'<Team_Drive_Id_Or_Folder_Id>' in parents and trashed=false", 'corpora': 'teamDrive', 'teamDriveId': '<Team_Drive_Id>', 'includeTeamDriveItems': True, 'supportsTeamDrives': True}).GetList()
Run Code Online (Sandbox Code Playgroud)
如何使用 PyDrive 访问团队云端硬盘而不是个人 Google 云端硬盘?
| 归档时间: |
|
| 查看次数: |
3234 次 |
| 最近记录: |