struct.unpack 上的 Python MemoryError

标签 python memory unpack

当我尝试解压从文件中读取的数据时,出现MemoryError。我希望能够读取每个字节,这就是我解压它的原因。当我仅解压 1 个字节时,它可以工作,但是当我想读取整个转储 (total_size) 时,它会给出错误。我不知道该怎么办。

def read_memory(self, mem_file, address, byte_count):
        mem_file.seek(address)
        data = mem_file.read(byte_count)
        return data

memory_dump = self.read_memory(mem_file, start_addr, total_size)
unpacked = struct.unpack("{}B".format(total_size), memory_dump) # MemoryError

我该如何解决这个问题?

最佳答案

好像我没有足够的内存

关于struct.unpack 上的 Python MemoryError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40706876/

相关文章:

python - MariaDB 在 python 中检查连接状态

python - 如何将 for 循环中的所有用户输入保存到文本文件中

c++ - 在字节数组上转换具有虚函数的结构是否安全?

c - 如何重新分配结构数组

c++ - 将可变类型列表解压到变量

python - 如何在 python 中将 16 位 PCM 数据转换为 float ?

python - 在 Python 中返回数组中最大元素的索引

c++ - Python 比 C++ 更快更轻吗?

actionscript-3 - 如何使用 Adob​​e Air 下载和解压 .ZIP 文件夹?

python - 无法在 OS X 上将 MySQL 导入到 python 中