我正在努力清理我的谷歌服务帐户中的一些空间。我一直在用它来处理电子表格,我想删除一些我以前创建的电子表格。要删除电子表格,有if函数gc.Delu电子表格(文件id)在gspread中。但是,我找不到检索要删除的电子表格的文件ID的方法。你知道吗
我找不到一种方法来打开谷歌驱动器的服务帐户像谷歌驱动器的个人帐户。因此,我使用下面的代码列出了截至目前帐户中的所有电子表格。代码输出电子表格标题,但不输出删除电子表格所需的文件id。你知道吗
def upload_to_google_sheets():
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name("client.json", scope)
gc = gspread.authorize(credentials)
print('authorized')
titles_list = []
for spreadsheet in gc.openall():
titles_list.append(spreadsheet.title)
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(titles_list)
upload_to_google_sheets()
最终的目标是使用gspread del_电子表格功能删除电子表格,该功能需要“file_id”。你知道吗
如果我的理解是正确的,这个修改怎么样?你知道吗
发件人:
收件人:
for spreadsheet in gc.openall():
的对象spreadsheet
包含电子表格IDspreadsheet.id
。你知道吗通过此修改,您可以检索以下结果。你知道吗
参考文献:
如果我误解了你的问题,而这不是你想要的结果,我道歉。你知道吗
相关问题 更多 >
编程相关推荐