我想从使用 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/