网络编程
位置:首页>> 网络编程>> Python编程>> Python第三方库h5py_读取mat文件并显示值的方法

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

作者:CodeTutor  发布时间:2022-06-24 15:48:57 

标签:Python,h5py,mat

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'

来源:https://blog.csdn.net/VictoriaW/article/details/73459738

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com