python读取npz文件,如何查看npz文件中的数据对象内容?

I am using Spyder IDE and Python 2.7.

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')

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".

When I just type

data

I get something like this:

array({'a': array([ 1,2,3, ...,

4,5,6]), 'b': 10, 'c': array([-1,-2,-3]), 'd': 25, 'e': 1}, dtype=object)

How do I access 'a', 'b', 'c', 'd', etc?

解决方案

to obtain a list of all the constituent files, simply use:

$ data.files

你可能感兴趣的:(python读取npz文件)