Python google drive API 下载,文件在哪里?

mic*_*.70 4 python google-drive-api

我使用这里找到的 python 代码下载谷歌驱动器上的文件:https : //developers.google.com/drive/v3/web/manage-downloads 我有这个范围:https : //www.googleapis.com/auth /drive 似乎一切正常,我读到:

Download 35%.
Download 71%.
Download 100%.
Run Code Online (Sandbox Code Playgroud)

但是文件在哪里?在与python文件相同的目录中,什么都没有,既不是root,也不是home……你有想法吗?或者我该如何调试?

fur*_*ras 9

Google 文档中的示例使用

fh = io.BytesIO()
Run Code Online (Sandbox Code Playgroud)

所以它将数据读入内存并且不保存在磁盘上。

您必须使用(例如)保存它

open(..., 'wb')
write(fh)
close()
Run Code Online (Sandbox Code Playgroud)

编辑:其他人的信息-如@michelle.70 发现的-我们可以使用

fh = io.FileIO(filename, 'wb') 
Run Code Online (Sandbox Code Playgroud)

代替 fh = io.BytesIO()