首页 > 解决方案 > 在 Jupyter Notebook 上运行程序时找不到 os.listdir(path) 路径

问题描述

我在 Windows 10 上的 jupyter 笔记本上工作,试图运行以下程序:

ad = 'C:\\Users\\S m\\mbdataset\\trainmbds'
CAT = ['0 to 10','10 to 20','20 to 30','30 to 40','40 to 50']
for cat in CAT:
 path = os.path.join(ad, cat)
  for img in os.listdir(path):
    img_array = cv2.imread(os.path.join(path,img))
     plt.imshow(img_array)
      plt.show
      break
    break 

在上面的返回中,我收到以下错误:

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\S m\\mbdataset\\trainmbds\\0 to 10'

虽然,地址0 to 10C:\Users\S m\mbdataset\trainmbds\0 to 10另外,我尝试用各种斜杠(/,\和\\)写地址,它显示相同的错误。我遇到这个问题是因为我的文件路径地址中有太多空格?

标签: pythonwindowskerasjupyter-notebookoperating-system

解决方案


推荐阅读