Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python3中的异常处理从文件夹中删除特定图像_Python_Opencv_Python 3.5 - Fatal编程技术网

如何使用python3中的异常处理从文件夹中删除特定图像

如何使用python3中的异常处理从文件夹中删除特定图像,python,opencv,python-3.5,Python,Opencv,Python 3.5,我在一个文件夹里有500张图片。我想在python中使用异常处理删除不可读的图像 当我使用: os.remove() 然后我收到一条错误消息: [WinError 3] The system cannot find the path specified: '-coast-ocean-horizon-sky-sunrise-sunset-dawn-atmosphere-plane-dusk-vehicle-flight-island-yellow-shadows-colors-holidays

我在一个文件夹里有500张图片。我想在python中使用异常处理删除不可读的图像

当我使用:

os.remove() 
然后我收到一条错误消息:

[WinError 3] The system cannot find the path specified: '-coast-ocean-horizon-sky-sunrise-sunset-dawn-atmosphere-plane-dusk-vehicle-flight-island-yellow-shadows-colors-holidays-hot-reflections-the-mediterranean-sea-sunset-sun-aegean-sea-atmosphere-of-earth-484653.jpg' "
从此

-coast-ocean-horizon-sky-sunrise-sunset-dawn-atmosphere-plane-dusk-vehicle-flight-island-yellow-shadows-colors-holidays-hot-reflections-the-mediterranean-sea-sunset-sun-aegean-sea-atmosphere-of-earth-484653.jpg') 

在循环中迭代时第一个图像是否不可读,如何解决?

删除时,必须传递图像文件的整个路径,而不是图像文件。图像和.exe文件应在同一文件夹中,否则传递图像的整个路径。