在映射函数的列表理解中传递命名参数



我正试图将参数传递给正在映射的函数。有没有办法清理或优化?

# Map resized images
resized_imgs = tuple(map(resize_image, all_img_steps, [None for img in all_img_steps], [output_height for img in all_img_steps]))

谢谢!

使用生成器表达式而不是映射。

resized_imgs = tuple(resize_image(img, None, output_height) for img in all_img_steps)

最新更新