cPickle and pickle

import cPickle as p
#import pickle as p

AddressListfile = 'AddressList.data' # the name of the file where we store the information

AddressList = {'Xiaopeng Yang': (18000001219, '18700000019@139.com')}

# Write to the file
f = file(AddressListfile, 'w')
c = p.dump(AddressList, f) #dump the object to a file
f.close()

del AddressList # remove the AddressList

#Read back from the storage
d = file(AddressListfile)
shoredlist = p.load(d)
print shoredlist

Output

================= RESTART: /Users/zhouxin/Desktop/cPickle.py =================
{'Xiaopeng Yang': (18000001219L, '18700000019@139.com')}
>>>

 It also creates AddressList.data. 

About .data document: 

data是数据保存的备份类文件。里面存放的是加密后的数据文件,如模型、贴图、源程序代码等。data文件打开的方式是不确定的,如果是:
  1、数据文件, 可以用txt或word直接打开
  2、vcd格式的影音文件,可以用meidaplayer打开!

About pickle : 

you can store any Python object in a file and then get it back later intact. This is called storing the object persistently. 

Use the cPickle module to store the objects persistently on your hard disk. 

 

 

转载于:https://www.cnblogs.com/XinZhou-Annie/p/7099131.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值