python - Python将数组附加到打开的文件
问题描述
我试图在计算过程中将 512x512 数组附加到文件中。数据太大而无法将它们存储在内存中,因此我想将数组附加到文件中。有多个文件必须扩展。这是我在一个小例子中的方法:
import numpy as np
array1 = np.random.rand(512,512)
array2 = np.random.rand(512,512)
arrayList = [array1,array2]
for number,i in enumerate(arrayList):
with open('path', 'ab') as f:
np.save(f, arrayList[number])
arrayTest = np.load('path')
文件越来越大,所以我认为数组是附加的,但如果我加载它们,里面只有一个数组。我认为数组没有以正确的方式堆叠,并且 np load 只是在加载第一个数组时识别它。
解决方案
推荐阅读
- android - 如何在 Android 的操作栏中自定义扩展的 SearchView?
- ethereum - 用于字节操作的 Solidity 代码无法使用带有 Solidity 0.8.0 的安全帽编译器进行编译
- laravel-8 - Laravel Model::create() 返回错误的 id
- python - 将带有列表和字典的字典转换为df
- java - 在缓冲区上打印元素,Flowable rxJava
- python - 如何更快地使用 pandas 快速处理 .csv 文件
- gcc - f951:内部编译器错误:非法指令:在 Octave 中安装软件包时出现 4
- python - 在列表中查找输入值
- c++ - 函数指针可以指向相同类型对象的集合吗?
- c# - 如何使用 SharePoint C# ConsoleApp 在任意一个列表中添加对应字段的值(每个列表中的字段会不同)