python 形成npz文件

import numpy as np

a = np.arange(12)

a.shape = 3,4

# 将数据存储为npy/npz

np.save('a.npy', a)

np.save('a.npz', a)

c = np.load('a.npy')

print('save-load:',c)

# 存储多个数组

b1 = np.array([[6, 66, 666],[888, 88,8]])

b2 = np.arange(0, 1.0, 0.1)

c2 = np.sin(b2)

np.savez('result.npz', b1,b2,sin_arry = c)

c3 = np.load('result.npz') # npz文件时一个压缩文件

print(c3)

print("数组b1:{}数组b2:{}数组sin_arry:{}".format(c3['arr_0'],c3['arr_1'],c3['sin_arry']))

 

posted @ 2023-04-23 05:52  myrj  阅读(125)  评论(0编辑  收藏  举报