C:\Users\Admin>python
Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "D:\Anaconda\lib\site.py", line 440, in register_readline
readline.read_history_file(history)
File "D:\Anaconda\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
self.mode._history.read_history_file(filename)
File "D:\Anaconda\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
for line in open(filename, 'r'):
UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 1421: illegal multibyte sequence
>>> import scipy
>>> from scipy import io
>>> z = scipy.io.loadmat("F:/googleCromeDownload/deepsea_train/test.mat")
>>> list(z.keys())
['__header__', '__version__', '__globals__', 'testdata', 'testxdata']
>>> z['testxdata'].shape
(455024, 4, 1000)
>>> z['testxdata'][1,:]
array([[0, 0, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 1],
[0, 1, 0, ..., 0, 0, 0],
[0, 0, 1, ..., 1, 1, 0]], dtype=uint8)
>>> z['testxdata'][1,:,:]
array([[0, 0, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 1],
[0, 1, 0, ..., 0, 0, 0],
[0, 0, 1, ..., 1, 1, 0]], dtype=uint8)
>>> z['testxdata'][1:3,:,:]
array([[[0, 0, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 1],
[0, 1, 0, ..., 0, 0, 0],
[0, 0, 1, ..., 1, 1, 0]],
[[0, 0, 0, ..., 0, 1, 1],
[0, 1, 1, ..., 1, 0, 0],
[1, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]]], dtype=uint8)
>>> z['testxdata'][1:455029,:,:]
array([[[0, 0, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 1],
[0, 1, 0, ..., 0, 0, 0],
[0, 0, 1, ..., 1, 1, 0]],
[[0, 0, 0, ..., 0, 1, 1],
[0, 1, 1, ..., 1, 0, 0],
[1, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
[[0, 1, 0, ..., 0, 0, 1],
[0, 0, 1, ..., 0, 1, 0],
[1, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 1, 0, 0]],
...,
[[0, 0, 0, ..., 0, 1, 1],
[0, 0, 0, ..., 0, 0, 0],
[0, 1, 0, ..., 0, 0, 0],
[1, 0, 1, ..., 1, 0, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 1, ..., 0, 0, 1],
[0, 0, 0, ..., 1, 0, 0],
[1, 1, 0, ..., 0, 1, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 1, 1, ..., 0, 0, 1],
[0, 0, 0, ..., 1, 0, 0],
[1, 0, 0, ..., 0, 1, 0]]], dtype=uint8)
>>>
有的会提示用hp5y读取
import h5py
data=h5py.File('cebi.mat','r')
x=list(data.keys())
#data[x[1]]
#w=data[x[1]]['wave']
www=data[data[x[1]]['wave'][0][0]].value