报错:TypeError: list indices must be integers or slices, not numpy.float64
代码:
new_idx = np.linspace(0, imgs_num, target_len+1)
int_idx = [round(i) for i in new_idx]
sub_list = [imgs_list[j] for j in new_idx]
原因: np.linspace生成的是numpy数组,不是List,需要先转换为list才能使用里面的元素做为index
new_idx = list(np.linspace(0, imgs_num, target_len+1))