调用python中的os模块,使用listdir读取文件夹的名字,然后将名字转化为整数,因为sort只有对整数才能正确排序。 a = os.listdir('imgs') a.sort(key=lambda x:int(x[3:-4]))