落盘,就是将数据写入到磁盘(存储介质);
刷盘,并不是每次接收到数据后就将数据写入到磁盘,而是会先写入缓冲区,将缓冲区的数据写入到磁盘的过程,称为刷盘。
import pickle #持久化,数据落盘
#1.pickle.dump(数据,文件管家):写操作
list01 = [10,"hehe",True]
# with open("/opt/bee/list.data",mode="wb") as fw:
# pickle.dump(list01,fw)
#2.pickle.load(文件管家):读操作
with open("/opt/bee/list.data",mode="rb") as fr:
data=pickle.load(fr)
print(data,type(data))
运行结果:(没有改变数据的类型)
/usr/local/bin/python3 /root/PycharmProjects/NSD211/test/demo7.py
[10, 'hehe', True] <class 'list'>
Process finished with exit code 0