如何查看npz文件中的数据对象内容? [英] How do I view data object contents within an npz file?
问题描述
我正在使用Spyder IDE和Python 2.7.
I am using Spyder IDE and Python 2.7.
我有一个名为data.npz的npz文件,该文件已提供给我.我想将此文件加载到Spyder中并查看其中的内容.
I have a npz file called data.npz which was given to me. I want to load this file into Spyder and view whatever is inside.
首先,我已完成此操作:
To start I've done this:
import numpy as np
data = np.load('data.npz')
在Spyder的变量浏览器中,我有一个名为数据"且类型为对象"的变量.当我双击该变量时,Spyder出现错误,提示当前不支持对象数组".
In my Variable Explorer in Spyder, I have a variable with the name "data" and the type "object". When I double-click on this variable, Spyder gives an error saying "object arrays are currently not supported".
当我输入时
data
我得到这样的东西:
array({'a': array([ 1,2,3, ...,
4,5,6]), 'b': 10, 'c': array([-1,-2,-3]), 'd': 25, 'e': 1}, dtype=object)
如何访问"a","b","c","d"等?
How do I access 'a', 'b', 'c', 'd', etc?
推荐答案
要获取所有组成文件的列表,只需使用:
to obtain a list of all the constituent files, simply use:
$ data.files
这篇关于如何查看npz文件中的数据对象内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!