根据我在网上阅读的内容,以下是Python读取包含整数数据的二进制文件的示例:
在Matlab中,我认为对应的命令是:
在Matlab中,完成使用文件后应使用
in_file = open('12345.bin', 'rb');
x = np.fromfile(in_file, dtype = 'int32');
在Matlab中,我认为对应的命令是:
in_file = fopen('12345.bin', 'rb');
x = fread(in_file, 'int32');
fclose(in_file);
在Matlab中,完成使用文件后应使用
fclose
关闭文件。在NumPy中是否有相应的操作?
in_file.close()
。然而,如果你忘记了这个步骤,当函数返回时,Python会自动关闭文件。 - inspectorG4dget