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

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

问题描述

我使用此处找到的python代码在Google驱动器上下载文件: 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文档中的示例使用

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天全站免登陆