对于h5py 如果我们直接cmd用pip进行下载
pip install h5py
这个时候收到报错,或者没有成功安装的提示。
笔主尝试了镜像源网址http://pypi.doubanio.com/simple/,还是没有成功
转到https://pypi.org/project/h5py/#files,下载对应版本的文件
笔主是python3.6,win64
下载后,将后缀.whl 改成.zip,解压后放在/python/Lib 文件下
有些博客中说h5py需要在HDF5安装后才能运行,
http://pypi.doubanio.com/simple/中可以找到
成功后会发现
原因主要是 python2.x 和 python3.x对keys方法的返回处理不同。官方说明如下:
When using h5py from Python 3, the keys(), values() and items() methods will return view-like objects instead of lists. These objects support containership testing and iteration, but can’t be sliced like lists.
python2 返回为list,而python3 返回为view-like objects,并不能直接查看。
解决方法:
1) 换成 python2.x 环境进行相同操作。 2) 采用如下代码:
key = [key for key in mydata.keys()] 注意:如果是cell的,那么读取到的数据是原数据的转置,需要转置回来。对于一般的array结构的.mat不存在转置。【参考】
https://blog.csdn.net/u013630349/article/details/47111773
