如何使用Drive API在Google电子表格中获取工作表(名称和"gid")列表?

luc*_*umi 18 python python-2.7 google-drive-api google-api-python-client

我正在尝试使用Google Drive API(Python)下载电子表格文件的某些标签.gid是文件元数据中的信息吗?我想做的是(这可能不正确,请建议:)):

file_metadata = self.service.files().get(file_id=file_id).execute()
# in the following line, how can I get a download url with a gid (a tab in a spreadsheet file)
download_url = file_metadata.get('exportLinks')['text/csv']
# download the file.
Run Code Online (Sandbox Code Playgroud)

谢谢:)

sor*_*rin 1

事实上,这似乎是如何将 Google 电子表格的工作表字符串 id 转换为整数索引(GID)?

这是快速回答:

def to_gid(worksheet_id):
    return int(worksheet_id, 36) ^ 31578
Run Code Online (Sandbox Code Playgroud)