当前位置: 首页 > 图灵资讯 > 行业资讯> python怎样读mat文件格式

python怎样读mat文件格式

发布时间:2025-03-07 22:10:55

mat数据格式是Matlab数据存储的标准格式,scipy可用于python.读取io中函数loadmat()的mat文件。

importscipy.ioasscio

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.,...,0.,0.,0.],
[0.,0.,0.,0.,0.,...,0.,0.,0.]])

python培训视频众多,全部在python学习网,欢迎在线学习!

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09