https://blog.csdn.net/weixin_39223665/article/details/85041775 python lee el archivo .mat de Matlab
https://blog.csdn.net/google19890102/article/details/45672305 python read file-python lee y guarda el archivo mat
En el problema real, el archivo .mat es una celda.
Leer con la biblioteca scipy
A través del método scipy.io.loadmat , los datos leídos están en formato de diccionario , que se puede ver a través del tipo de función (datos).
import scipy.io #用于加载mat文件
import numpy as np
labels = scipy.io.loadmat('F:\\imagelabels.mat') #用scipy.io.loadmat读取.mat文件
print("labels:",labels)
#输出:labels: {'__header__': b'MATLAB 5.0 MAT-file, Platform: GLNX86, Created on: Thu Feb 19 15:43:33 2009',
#'__version__': '1.0', '__globals__': [], 'labels': array([[77, 77, 77, ..., 62, 62, 62]], dtype=uint8)}
data_labels=labels.get('labels') #取出字典里的labels
print("data_labels:",data_labels)
#输出:data_labels: [[77 77 77 ... 62 62 62]]
labels = labels['labels'][0] #取出字典里的labels id
print("labels:",labels)
#输出:labels: [77 77 77 ... 62 62 62]