python如何对文件中的文件进行顺序遍历

如何对文件中的jpg进行顺序遍历, 其中jpg的文件名为0.jpg~200.jpg,


def get_images_list(image_dir, postfix=['*.jpg']):
    '''
    获得文件列表
    :param image_dir: 图片文件目录
    :param postfix: 后缀名,可是多个如,['*.jpg','*.png']
    :return:
    '''
    images_list = []
    for format in postfix:
        image_format = os.path.join(image_dir, format)
        image_list = glob.glob(image_format)
        if not image_list == []:
            images_list += image_list
    images_list = sorted(images_list)
    return images_list

os.walk()了解一下

import os

dir = './imgs/'
imgList = os.listdir(dir)
print(imgList)
imgList.sort(key=lambda x: int(x.replace("frame","").split('.')[0]))#按照数字进行排序后按顺序读取文件夹下的图片
print(imgList)
for count in range(0, len(imgList)):
im_name = imgList[count]
im_path = os.path.join(dir,im_name)
print(im_path)