如何使用python3中的异常处理从文件夹中删除特定图像
我在一个文件夹里有500张图片。我想在python中使用异常处理删除不可读的图像 当我使用:如何使用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
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文件应在同一文件夹中,否则传递图像的整个路径。