Python google drive API 下载,文件在哪里? [英] Python google drive API download, where is file?

查看:44
本文介绍了Python google drive API 下载,文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I used the python code found here to download a file on google drive: https://developers.google.com/drive/v3/web/manage-downloads I have this scope: https://www.googleapis.com/auth/drive everything seems to work, I read:

Download 35%.
Download 71%.
Download 100%.

但是文件在哪里?在与python文件相同的目录中,没有任何东西,既不是根目录,也不是主目录……你有想法吗?或者我该如何调试?

but where is the file? in the same directory as the python file, there is nothing, neither the root, nor in the home ... you have ideas? or alternatively how can I debug?

推荐答案

Google doc 使用示例

Example in Google doc uses

fh = io.BytesIO()

所以它将数据读入内存,而不是保存在磁盘上.

so it reads data into memory and it doesn't save on disk.

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

You have to save it using (for example)

open(..., 'wb')
write(fh)
close()

<小时>

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


EDIT: information for others - as @michelle.70 found - we can use

fh = io.FileIO(filename, 'wb') 

而不是 fh = io.BytesIO()

这篇关于Python google drive API 下载,文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆