Matlab的fread(fild,1,int32)迁移到python变成什么

Matlab的fread(fild,1,int32)迁移到python变成什么
我是用Matlab读取文件内的数据的。现在想迁移到python上识别但是。弄不来 希望有大神教一下

你的可能是二进制读取吧!
matlab读取:

fid = fopen('test.bin','w');
fwrite(fid, 88, 'int32');
fclose(fid);
fid2 = fopen('test.bin','r');
fread(fid,1,'int32')

python读取:

import numpy as np
def fread(fid, nelements, dtype):
     if dtype is np.str:
         dt = np.uint8  # WARNING: assuming 8-bit ASCII for np.str!
     else:
         dt = dtype
     data_array = np.fromfile(fid, dt, nelements)
     data_array.shape = (nelements, 1)
     return data_array

fid = open('test.bin', 'rb');
a = fread(fid,1,np.int32)

可以读入呢,我试过啦
有帮助还望给个采纳支持一下哟