numpy文件操作

import numpy as np

print '读取csv文件做为数组'
arr = np.loadtxt('array_ex.txt', delimiter = ',')
print arr

 

import numpy as np

print '数组文件读写'
arr = np.arange(10)
np.save('some_array', arr)
print np.load('some_array.npy')
print

print '多个数组压缩存储'
np.savez('array_archive.npz', a = arr, b = arr)
arch = np.load('array_archive.npz')
print arch['b']

 

posted @ 2018-08-22 23:23  Python少年  阅读(224)  评论(0编辑  收藏  举报