【发布时间】: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