查找谷歌共享驱动器文件夹 ID

时间:2021-07-26 17:40:19

标签: python google-drive-api

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth) 
def get_children(root_folder_id,param={'q': str},drive=drive):
    
    str = "\'" + root_folder_id + "\'" + " in parents and trashed=false"
    param["q"]=str
    file_list = drive.ListFile(param).GetList()
    return file_list

def get_folder_id(root_folder_id, root_folder_title,drive=drive):
    file_list = get_children(root_folder_id,drive=drive)
    for file in file_list:
        if(file['title'] == root_folder_title):
            return file['id']
get_folder_id("root", "YourFolderNameInRoot",drive=drive)

经过测试,这不能用于查找共享驱动器文件夹 ID 的名称。仅适用于“MyDrive”

我如何找到谷歌共享驱动器文件夹 ID。

1 个答案:

答案 0 :(得分:0)

查看 > dput(head(n2)) structure(list(pitch_type = c("FF", "SL", "FF", "SL", "FF", "SL" ), game_date.x = structure(c(18477, 18493, 18472, 18493, 18477, 18521), class = "Date"), release_speed = c(99.2, 88.2, 96.5, 88.4, 98.3, 92.1), release_pos_x = c(-0.87, -2.03, -1.8, -1.8, -1.03, -1.32), release_pos_z = c(5.62, 5.52, 5.71, 5.66, 5.63, 5.64), player_name = c("deGrom, Jacob", "Cole, Gerrit", "Cole, Gerrit", "Cole, Gerrit", "deGrom, Jacob", "deGrom, Jacob"), pfx_x = c(-0.53, 0.46, -1, 0.53, -0.56, 0.33), pfx_z = c(1.39, 0.18, 1.54, 0.28, 1.33, 0.52), plate_x = c(1.26, 1.47, -0.54, 0.57, -0.34, 0.34 ), plate_z = c(1.86, -0.14, 2.32, 2.11, 3.3, 1.88), release_spin_rate = c(2333L, 2571L, 2509L, 2496L, 2443L, 2687L), release_extension = c(7, 6.5, 6.7, 6.3, 7, 6.8), spin_axis = c(218L, 105L, 220L, 141L, 212L, 161L)), row.names = c(NA, 6L), class = "data.frame") 的文档后,pydrive 不支持 Google Drive APIDrive.Drives.List 方法。

pydrive 将列出用户的共享驱动器,其中包含共享驱动器的名称和 ID 作为响应的一部分。

示例:

enter image description here

这是一个 Drive.Drives.List 在 python 中的使用示例。

进一步阅读: