import numpy as np
import os
# ----------------------------------------------------用户输入
path = 'F:/mytest/' # 输入文件路径
index = 'EOD' # 文件的开头几个字符,以免遍历了多余的文件,需根据自己的文件输入
outpath = 'F:/mytest ' # nc文件输出目录
#---------------------------------------------------------
files = [f for f in os.listdir(path) if f.startswith(index)] # 遍历文件夹的数据
for file in files:
with open(path+file, 'rb') as f: # 用with open 打开文件
a = np.fromfile(f, dtype=np.float32) # 把二进制文件转为可读的数字
a = np.reshape(