# pickle:序列化和反序列化

我们可以通过python中的pickle模块实现序列化和反序列化。

  • 序列化:将程序中运行的对象信息保存到文件中去,永久存储。
  • 反序列化:从文件中创建上一次程序保存的对象。

# 基本语法

pickle.dump(obj, file, [,protocol])
x = pickle.load(file)
# file: 类文件对象,有read()和readline()接口。