import PIL.Image as Image def get_gif(pics_dir,n,t=0.1): imgs = [] for i in range(n): pic_name = '{}/{}.png'.format(pics_dir,i) temp = Image.open(pic_name) save_name = '{}.gif'.format(pics_dir) imgs[0].save(save_name, save_all=True, append_images=imgs, duration=t) return save_name if __name__ == '__main__': pics_dir = 'rileDog' save_name = get_gif(pics_dir,8,0.2) print('制作完成。所属文件:{}'.format(save_name))