numpy savetext格式的帮助会产生错误

时间:2019-06-28 11:05:33

标签: python numpy

我必须将摄像机距离导出到txt /数据文件。 当我在工作时出现错误时。

任何想法如何克服它。

未发布完整的代码

perimeter = cv2.arcLength(cnt,True)

g = float("{0:.2f}".format(perimeter))

timestamped_camera_readings = np.append(timestamped_sensor_readings, (((154*58)/(g/4))*0.2645 ))

with open("camera_diatance.txt", "ab") as f:
    np.savetxt(f, np.expand_dims(timestamped_camera_readings, axis=0),  fmt=write_fmt)

将其保存到文件

Error raised:
Traceback (most recent call last):
File "/home/pi/merger/merger.py", line 118, in <module>
np.savetxt(f, np.expand_dims(timestamped_camera_readings, 
axis=0),fmt=write_fmt)
File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 1196, in 

保存文本     引发错误      ValueError:fmt的%格式数量错误:%4.2f%4.2f%4.2f%4.2f     %4.2f%4.2f%4.2f%4.2f%.0f

0 个答案:

没有答案