当前位置:主页 > 软件编程 > Python代码 >

Python第三方库h5py_读取mat文件并显示值的方法

时间:2021-03-22 09:08:22 | 栏目:Python代码 | 点击:

mat数据格式是Matlab默认保存的数据格式。在Python中,我们可以使用h5py库来读取mat文件。

>>> import h5py
>>> data = h5py.File("**.mat")
>>> test = data["digitStruct/name"] #<HDF5 dataset "name": shape (13068, 1), type "|O">
>>> st = test[0][0] #<HDF5 object reference>
>>> obj = data[st] #<HDF5 dataset "b": shape (5, 1), type "<u2">
>>> str = "".join(chr(i) for i in obj[:])
>>> str
'1.png'

您可能感兴趣的文章:

相关文章