我有biary文件,标头+ 4字节长整数值的集合。
用struct.unpack
解压缩标头后,我创建剩余值的数组。
int_values = array.array('l')
int_values.fromfile(binary_input, self.columns * self.rows)
在Windows下,一切都按预期工作。 在我的Linux(Ubuntu 12.04)下,我收到以下错误:
int_values.fromfile(byn_input, self.columns * self.rows)
EOFError: not enough items in file
默认情况下,似乎Ubuntu 'l'
下的长度为8个字节。
使用struct,我可以通过前缀'=, <, >, !'
我怎么能强制array('l')
长4个字节,尽管默认为8个字节?