从 google colab 中的共享 google drive 链接下载数据

标签 download html-lists google-colaboratory drive

我想从使用 google colab 的人共享的 google drive 链接下载数据。我是 colab 的新用户,我不知道该怎么做。
链接是
x_train: https://drive.google.com/open?id=1cUaIEd9-MLJHFGjLz5QziNvfBtYygplX
y_train:https://drive.google.com/open?id=1hv24Ufiio9rBeSqgnNoM3dr5sVGwOmBy
x_test: https://drive.google.com/open?id=1AH9lKHT5P2oQLz8SGMRPWs_M9wIM2ZRH
y_test: https://drive.google.com/open?id=1i4_azocSDuU3TcDf3OSHO1vF0D5-xMU6
提前致谢

最佳答案

您可以使用 gdown如果文件是公开共享的。

!gdown --id 1cUaIEd9-MLJHFGjLz5QziNvfBtYygplX
如果它只分享给你,你需要使用 pydrive
# Install the PyDrive wrapper & import libraries.
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

file_id = '1cUaIEd9-MLJHFGjLz5QziNvfBtYygplX'
downloaded = drive.CreateFile({'id':file_id})
downloaded.FetchMetadata(fetch_all=True)
downloaded.GetContentFile(downloaded.metadata['title'])
如果他们共享一个文件夹,它太长了,所以我在我的图书馆里把它缩短了。
!pip install kora
from kora import drive
drive.download_folder('1HvIeNhqtFVllXFWzH5NawDdnIfgGDwCK')

关于从 google colab 中的共享 google drive 链接下载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62759748/

相关文章:

javascript - 如何创建没有嵌套列表的下拉菜单?

css - 当元素符号有背景时如何缩进列表中的第二行?

python - 我忘记关闭 tf.InteractiveSession,如何终止任何剩余进程?

PHP ZIP 文件下载

html - 带有渐变图像背景的 WordPress 子菜单悬停在父 LI 和子 LI 的上方(子菜单 UL)

python - 在 Google Colab 上的 R 笔记本中安装 python 库

tensorflow - InvalidArgumentError : Unsuccessful TensorSliceReader constructor: Failed to get matching files . .. 文件系统方案 '[local]' 未实现

r - 一键下载 R Shiny 的两个输出

javascript - 如何从服务器下载文件并通过对话框保存

mongodb - 如何使用 Liferay 在 portlet 中下载文件或 InpuStream?