python-3.x - 我在尝试创建 for in 循环时收到 FileNotFoundError
问题描述
我正在制作一个image classifier
. 我已经成功创建了文件夹,并且我手动将必须从 google 放入的.txt files
文件links
夹images
放入每个文件夹中。
我现在正在尝试将download
每个图像中的图像.txt file
either
放入每个文件夹类别内的文件夹中,or
放入每个也具有 .txt 文件的类别文件夹中,但是我不断收到错误消息。请帮忙。
我将它们manually
放在.txt files
每个文件夹中,就像它们在父文件夹名称中一样PLANTS
,但这并没有什么不同。
我希望从带有谷歌图像链接的 .txt 文件中将所有图像下载到各自的文件夹中,但它不起作用,无论 .txt 是在主 PLANTS FOLDER 内还是在 PLANTS 文件夹内的每个类别文件夹内
相反,我收到以下错误
FileNotFoundError
请参阅随附的屏幕截图
&
解决方案
Long filenames or paths with spaces are supported by NTFS in Windows NT. However, these filenames or directory names require quotation marks around them when they are specified in a command prompt operation. Failure to use the quotation marks results in the error message.
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]
Note: its better practice to write folder/file name without
space
more info
推荐阅读
- javascript - 单击时显示文本并禁用复选框
- python - EbaySDK Python GetFeedback (ItemID) 仅返回 100 个值
- c - 内存地址
- c++ - 使用友元声明继承私有 CRTP 构造函数
- vba - 进一步应用修改后刷新 Outlook mailitem.display
- reactjs - 如何在反应中将变量放在引号内
- assembly - BIOS。LBA 模式读取不读取扇区
- ios - iOS 12 不支持部分 PWA 的离线功能
- ubuntu - neo4j 控制台无法启动。错误:JAVA_HOME 定义不正确
- android - 在不知道以前的密钥库的情况下安装 apk