我有如下数组:
X = np.array([image_array_to_vector1,image_array_to_vector2,image_array_to_vector3,image_array_to_vector4])
X
的打印输出如下:
[array([167, 167, 169, ..., 1, 1, 1], dtype=uint8)
array([42, 43, 43, ..., 41, 36, 34], dtype=uint8)
array([0, 0, 0, ..., 0, 0, 0], dtype=uint8)
array([0, 0, 0, ..., 0, 0, 0], dtype=uint8)]
当我尝试将数据保存为txt文件时:
X_to_text_file = np.savetxt('x.txt',X)
我得到以下内容:
File "/Library/Python/2.7/site-packages/numpy/lib/npyio.py", line 1258, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('object') and format specifier ('%.18e')
为什么会这样?我该怎么解决这个问题呢?谢谢。