我在试图直接用python分析HDF5文件中的数据时遇到了这个错误。这段代码在我的linux机器上运行得很好,但我在Spyder3的mac上编译同一个脚本时遇到了这个错误。我之所以尝试使用mac是因为我不知道如何在linux终端上编写和运行脚本
def dataProcessing(datafile):
import h5py
import numpy as np
import matplotlib.pyplot as plt
import pylab
f = h5py.File(datafile, 'r')
#print(f)
#print("Keys: %s" % f.keys())
groupKeyVal = f.keys()[4]
rawData = list(f[groupKeyVal])
rawDataMat = np.matrix(rawData)
for i in range(0,len(rawDataMat[:,0])):
fig = rawDataMat[i,:]
wav = np.squeeze(np.asarray(fig))
plt.plot(wav)
plt.show()
在Python3中,dictionary
keys
返回一个“视图”,而不是一个可索引列表类似地,对于来自
h5
组的类似字典的键添加
list
有点麻烦,但它使键上的迭代更加高效相关问题 更多 >
编程相关推荐