Python之保存和读取字典

import pickle
def save_obj(obj, name ):
    with open('obj/'+ name + '.pkl', 'wb') as f:
        pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)

def load_obj(name ):
    with open('obj/' + name + '.pkl', 'rb') as f:
        return pickle.load(f)

 

posted @ 2018-08-29 14:16  Shiyu_Huang  阅读(14393)  评论(0编辑  收藏  举报