问题背景
python读文件夹下的文件如果是直接获取文件列表的话,得到的是1,10,11,12,13,14,15,16,17,18,19,2,20,21…
现在想要得到1,2,3,4,5,6,7,8,9,10,11,12…的顺序
解决方案
import os
import cv2
for i in range(1,10):
file1 = 'clothes_image_label/newclothesdataset/%d.jpg'%i
print(file1)
img = cv2.imread(file1)
更多推荐
【Python3语法】按照指定目录下文件名中的数字大小读取文件
发布评论