当前位置:网站首页>学习 pickle
学习 pickle
2022-06-27 23:18:00 【qq_39239110】
Python 提供的pickle 模块可以用来序列化对象并保存到磁盘中,并在需要的时候读取出来,任何对象都可以执行序列化操作。
例如转换一个列表:
list = [123,3.14,‘小甲鱼’,[‘another list’]]
一般基本操作为:
第一步:先以二进制的方式打开一个文件,若文件不存在就会自动创建该文件。
pickle_file = open(‘list.pck’,‘wb’);
第二步: 用dump 函数将list对象序列化到已经打开的文件中去。
pickle.dump(list,pickle_file);
如果想读取序列化的对象,它的基本的操作如下:
第一步: 以二进制的方式读取一个文件。
pickle_file2 = open(‘list.pck’,‘rb’);
第二步: 用load()将file中的对象序列化读取出来
list_1 = pickle.load(pickle_file2);
边栏推荐
- 评价——秩和比综合评价
- Set集合用法
- Is it safe for Xiaobai in the stock market to open an account on the Internet?
- From small to large, why do you always frown when talking about learning
- 同花顺股票开户是会有什么风险吗?同花顺开户安全吗
- 想开户买股票,在网上办理股票开户安全吗?
- Transformer论文逐段精读
- Is it safe to open an account online now? Novice is just on the road, ask for the answer
- 单晶炉导电滑环的应用范围和作用是什么
- Golang monkeys eat peaches and ask for the number of peaches on the first day
猜你喜欢
Web3 technology initial experience and related learning materials
Meituan dynamic thread pool practice idea has been open source
What is a through-hole conductive slip ring?
如何在您的Shopify商店中添加实时聊天功能?
什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?
What is the application scope and function of the conductive slip ring of single crystal furnace
TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
MapReduce elementary programming practice
[Niuke discussion area] Chapter 4: redis
How to build dual channel memory for Lenovo Savior r720
随机推荐
现在网上开股票账户安全吗?选择上市券商,最快8分钟开户成功
LMSOC:一种对社会敏感的预训练方法
lefse分析本地实现方法带全部安装文件和所有细节,保证成功。
数据人面试指南 | 准备好这几点做到有备无患!
LATEX 表格内容居左,中,右
I/O限制进程与CPU限制进程
Drug interaction prediction based on learning size adaptive molecular substructure
How to optimize the "message" list of IM
Download, configuration and installation of MySQL
[Niuke discussion area] Chapter 4: redis
机器学习笔记 - 时间序列作为特征
现在炒股网上开户安全吗?新手刚上路,求答案
声网 VQA:将实时互动中未知的视频画质用户主观体验变可知
大尺寸导电滑环市场应用强度如何
How about the market application strength of large-size conductive slip rings
电商转化率这么抽象,到底是个啥?
【DNS 解析】将Name.com的域名接入DNSPod解析
【说明】Jmeter乱码的解决方法
What is the e-commerce conversion rate so abstract?
What is the application scope and function of the conductive slip ring of single crystal furnace