Python中的问题-仅将最后一个numpy数组写入.csv文件,而不是将所有数组附加到其后。如何解决此问题?
import cv2, glob
from PIL import Image
import numpy as np
images = glob.glob('*.bmp')
for image in images:
img=cv2.imread(image,0) #original image
re=cv2.resize(img, dsize=(128,128), interpolation=cv2.INTER_LINEAR)
cv2.imwrite("resized_"+image,re) #resized image
a = np.asarray(re) #resized image is converted to pixels
np.savetxt("sal.csv",a, delimiter=',')
print(np.asarray(re)) #which are printed to csv file. Problem is only the last image pixel values are printed to csv file. Any suggestions to rectify this.