pkl文件的读取、写入与合并

pkl文件的读取、写入与合并

    • 1.pkl文件的读取
    • 2.pkl文件的写入
    • 2.pkl文件的合并

1.pkl文件的读取

import pickle
inf = pickle.load(open('D:\\projects\\ncData\\weekly_average.pkl',"rb+"))
print(inf.keys())#查看pkl文件中的键值
print(inf)#读取数据
for var in inf.keys():
     data3=inf[var][:]
     print(var,data3.shape)
     #查看各键值对应的shape

pkl文件的读取、写入与合并_第1张图片

2.pkl文件的写入

import pickle
with open('D:\\projects\\ncData\\test_sst_u_v_wind_u_v_current_pre_weekly_average_20190101-20201228.pkl',"rb+") as f2:
    data_daily_inference2=pickle.loads(f2.read())
    for i in range(0

你可能感兴趣的:(python,python)