【发布时间】:2020-10-23 06:48:16
【问题描述】:
我想使用 Python 的 Visual Studio Code 上的 Google Drive API 直接从 Google Drive 读取文件。
这是部分代码:
file2 = drive.CreateFile({'id': file1['<the file ID of my file that is inside the Google Drive>']})
file2.GetContentString('testing.csv')
运行后,我得到一个
KeyError: KeyError('<the file ID of my file that is inside the Google Drive>')
我在互联网上搜索了解决此问题的可能方法,但到目前为止似乎没有任何效果......
我遵循了这个教程:Hands-on tutorial for managing Google Drive files with Python
【问题讨论】:
-
file2 = drive.CreateFile({'id': file1['id']})file2.GetContentFile('testing.csv') -
@ChatterOne 我仍然遇到同样的错误...
-
@user14489561 你的声明说你想从谷歌驱动器读取文件。您的代码显示您正在尝试在 google drive 中错误地创建文件。你到底想做什么?
-
@DalmTo 在读取 csv 文件的数据(存储在 google 驱动器中)并在我的 Visual Studio 代码的输出终端中显示 csv 文件的数据
标签: python python-3.x google-api google-drive-api google-api-python-client