首页 > IT职业 > IT职场 > python怎样读mat文件格式

mat数据格式是Matlab的数据存储的标准格式,在python中可以使用scipy.io中的函数loadmat()读取mat文件。
import scipy.io as scio path = 'ex3data1.mat' data = scio.loadmat(path) type(data) dict #data是字典格式 data.keys() #查看字典的键 dict_keys(['__header__', '__version__', '__globals__', 'X', 'y']) X1 = data['X'] #选择需要的数据;数组格式 array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]])
众多python培训视频,尽在python学习网,欢迎在线学习!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2530/viewspace-2834998/ ,如需转载,请注明出处,否则将追究法律责任。