【问题标题】:Access local folder in colab访问 colab 中的本地文件夹
【发布时间】:2020-10-02 12:08:44
【问题描述】:

我想在 colab 中创建一个函数来一个一个地从文件夹中读取文件。 我在下面尝试过,即我将我的文件夹上传到我的云端硬盘,然后尝试从那里访问它。 但是,它仍然显示错误。

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

mypath = "/gdrive/My Drive/resume pdf" #enter your path here where you saved the resumes
onlyfiles = [os.path.join(mypath, f) for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f))]

错误-->

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-15-a7a8abc74cc6> in <module>()
      1 mypath = "/gdrive/My Drive/resume pdf" #enter your path here where you saved the resumes
----> 2 onlyfiles = [os.path.join(mypath, f) for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f))]

FileNotFoundError: [Errno 2] No such file or directory: '/gdrive/My Drive/resume pdf'`enter code here`

我已检查我的驱动器中是否有一个名为“resume pdf”的文件夹。 那么如何在colab中上传一个本地文件夹并一个一个地访问它的每个文件呢??

【问题讨论】:

    标签: google-colaboratory folder-access


    【解决方案1】:

    您将它安装在/content/gdrive,但您尝试在/gdrive 访问它,这就是错误。

    改成

    mypath = "/content/gdrive/My Drive/resume pdf"
    

    【讨论】:

      猜你喜欢
      • 2019-03-03
      • 1970-01-01
      • 2020-12-05
      • 2019-05-08
      • 1970-01-01
      • 2020-03-22
      • 2018-11-16
      • 2019-05-20
      • 2021-08-12
      相关资源
      最近更新 更多