Skip to main content
 首页 » 编程设计

python之hdf5storage.write() 没有保存到给定的路径

2024年12月31日8unruledboy

我想使用hdf5storage包在Matlab 7.9兼容文件中保存一个numpy数组,mat_dir是将文件保存到目录的路径,但是, hdf5storage.write() 将 mat 文件写入当前目录。这是什么原因?

   matfile = {} 
   matfile[u'image'] = myimage  
   hdf5storage.write(matfile, mat_dir, mat_file_name, matlab_compatible=True) 
   ##mat_dir=/home/user/workspace/img/ 

请您参考如下方法:

我可以使用另一个函数来解决它:

hdf5storage.savemat(os.path.join(mat_dir, mat_file_name), {'image': myimage}, format='7.3')  

并成功保存到给定的目录。