如果想同时在两个列表中取值的话,可以使用zip:
for i,j in zip([0,1,2],[0,1,2]) :
print(i,j)
结果为:
0 0
1 1
2 2
来进行高阶的写法:
for image,mask in zip([image0,image1,image2],[mask0,mask1,mask2]):
rotated_img = image.rotate(
skewing_angle if not random_skew else random_angle, expand=1
)
rotated_mask = mask.rotate(
skewing_angle if not random_skew else random_angle, expand=1
)