python - 在 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 10
是C:\Users\S m\mbdataset\trainmbds\0 to 10
另外,我尝试用各种斜杠(/,\和\\)写地址,它显示相同的错误。我遇到这个问题是因为我的文件路径地址中有太多空格?
解决方案
推荐阅读
- python - 如何使用 Dask 从 SQL 中读取数据
? - typescript - TypeScript:更新联合类型中的公共属性时出错
- batik - 引起:org.apache.batik.transcoder.TranscoderException:null 封闭异常:null:0 元素上的 URI无法打开,因为
- rabbitmq - 如何在不重启的情况下更改 RabbitMQ 心跳
- python - 格式化整数输出时出现问题
- python - 为什么我得到这个 ImportError 但函数仍然有效?
- c# - 解析json文件以获取数据
- mysql - 在 sequelize 中按关联表值查找总和和分组
- ruby-on-rails - Docker、Rails、Postgres - 找不到数据库服务错误
- android - 内容提供者以异步方式返回游标