我只花了约30分钟调试和反复检查Python&;C代码,以发现我的struct.pack写入了错误的数据。当我把它分成不同的调用时,它工作得很好
这是我以前吃过的
file.write(struct.pack("fffHf", kf_time / frame_divisor, kf_in_tangent, kf_out_tangent, kf_interpolation_type, kf_value))
这就是我现在拥有的
file.write(struct.pack("f", kf_time / frame_divisor))
file.write(struct.pack("f", kf_in_tangent))
file.write(struct.pack("f", kf_out_tangent))
file.write(struct.pack("H", kf_interpolation_type))
file.write(struct.pack("f", kf_value))
为什么第一个变体没有写入我期望的数据?和单独写这些东西有什么不同
(文件以二进制模式打开,平台为64位Windows,Python 3.5)
大概是因为,正如
struct
文档明确指出的那样:相关问题 更多 >
编程相关推荐