我正在尝试将参数传递给正在映射的函数。有没有办法清理或优化它?
# 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]))
谢谢!
最佳答案
使用 generator expression而不是 map 。
resized_imgs = tuple(resize_image(img, None, output_height) for img in all_img_steps)
关于python - 在映射函数的列表推导式中传递命名参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64473276/