python读取npy和dat文件信息
前言
python读取.dat
和 .npy
数据
Code
import numpy as np def read_dat():print("read data .dat \n")path = "./c1_input.dat"data = np.fromfile(path, np.float16).reshape(4,38,800)print(f'data :{data}, data shape:{data.shape}, data dtype:{data.dtype}\n')print("read input data done \n")def read_npy():print("read data .npy \n")path = "./c1_input.npy"data = np.load(path)print(f'data :{data}, data shape:{data.shape}, data dtype:{data.dtype}\n')print("read input data done \n")if __name__ == "__main__":read_dat()read_npy()