python - numpy savetext 格式的帮助会产生错误
问题描述
我必须将相机距离导出到 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
savetxt 引发错误 ValueError:fmt 的 % 格式数量错误:%4.2f %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f %.0f
解决方案
推荐阅读
- apache-camel - Apache Camel sjms 批处理失败
- ios - 调用时AnimationView不出现
- java - 如何在Java中输出格式化的excel文档
- f# - 为什么 FParsec 不使用解析列表分隔符的字符?
- java - 将 String x = "[]" 映射到 JsonNode 会导致额外的引号(Spring Boot)
- python-3.x - 将文件从 Colab 上传到 Google Drive 文件夹
- android - ListView 使用凌空
- powershell - 如何使用powershell从字符串中打印奇数字符
- swift - 数据是否写入到写入后返回的 BLE 特征
- web-services - weblogic上的springboot应用程序收到超时异常