尝试创建for in循环时,我收到FileNotFoundError

时间:2019-10-01 19:55:01

标签: python-3.x jupyter-notebook google-colaboratory fast-ai

我正在制作image classifier。我已经成功创建了文件夹,并手动将.txt files到Google的linksimages放置在每个文件夹中。

我现在正尝试将每个文件夹中download .txt file的图像either放入每个文件夹类别中的文件夹or放入每个类别文件夹也都有.txt文件,但是我一直收到错误消息。请帮忙。

manually.txt files放在每个文件夹中,就像它们在父文件夹名称中以PLANTS一样,但这没有什么区别。

我希望从带有google图像链接的.txt文件中将所有图像下载到其各自的文件夹中,但是无论.txt是在主植物文件夹内还是在植物内部的每个类别文件夹中,它都无法正常工作文件夹

相反,我得到以下错误

FileNotFoundError

请参阅附件的屏幕截图

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

Windows NT中的NTFS支持长文件名或带空格的路径。但是,在命令提示符操作中指定它们时,这些文件名或目录名称必须在其两边加上引号。无法使用引号导致错误消息。

 for i in range(len(folders)):
        path = "content/gdrive/My Drive/Colab Notebooks/Flowers/PLANTS"
        #for creating directory we need path class object so below this: 
        dest_for_creating_directory = path/folders[i]
        #for searchi directory which have spaces we need doubleQuotations that  
        #why user below one in download image function instead of dest. 
        dest_for_searching_directory = path+"/"+folders[i]
  

注意:在不使用space more info

的情况下写文件夹/文件名是一种更好的做法