myFolders = os.listdir(pathe)
for folders in myFolders:
# 将文件名的后缀去除
folders = int(folders.replace(".jpg",""))
sort_arr.append(folders)
# 对文件夹中的文件编号进行排序
sort_arr.sort()
for folder in sort_arr:
folder = str(folder)
# 获得按文件命名数字大小重新排序后的文件路径
path = pathe + '/' + folder + ".jpg"
print(path)
How does Python traverse the image files in the folder according to the file name and size
Guess you like
Origin blog.csdn.net/weixin_46235937/article/details/129303886
Ranking