【问题标题】:Accessing files in Google Colab在 Google Colab 中访问文件
【发布时间】:2020-03-22 02:46:28
【问题描述】:

我是 Google Colab 的新手。我使用以下代码从 Kaggle 下载了一个数据集:

!pip install kaggle

import os
os.environ['KAGGLE_USERNAME'] = "xxxxxxxxx"
os.environ['KAGGLE_KEY'] = "xxxxxxxxxxxxxxxxxxxxxxxxxx"

!kaggle competitions download -c dogs-vs-cats-redux-kernels-edition

os.chdir('/content/')
#dowloaded data in this directory

我现在可以访问所有数据,但是这些数据存储在哪里?在我的 Google 云端硬盘中?但我找不到它。如果我想从 Colab 中运行的不同笔记本访问相同的数据怎么办?两个笔记本都存储在我的 Google Drive 中,但似乎有自己不同的“/content/”文件夹。

【问题讨论】:

    标签: google-colaboratory


    【解决方案1】:

    要将数据存储在谷歌驱动器中,您必须首先使用链接驱动器:

    from google.colab import drive
    drive.mount('/content/drive')
    

    然后您可以通过"/content/drive/My Drive/" 导航访问驱动器

    因此您可以使用以下命令将数据下载到您的驱动器:

    !kaggle competitions download -p "/content/drive/My Drive/" -c dogs-vs-cats-redux-kernels-edition
    

    【讨论】:

      猜你喜欢
      • 2018-08-18
      • 2019-05-20
      • 2020-12-05
      • 2018-10-26
      • 2018-07-07
      • 1970-01-01
      • 2019-05-08
      • 2019-12-16
      • 2021-04-14
      相关资源
      最近更新 更多