pickle序列化 with open(fname, 'wb') as f: pickle.dump(data, f, protocol=2) with open(fname, 'rb') as f: data = pickle.load(f)