继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

python 中cPickle学习

慕仔4209126
关注TA
已关注
手记 304
粉丝 69
获赞 305

写入:

import cPickle as p

shoplistfile = 'data.data'

shoplist = ['meili',['current_account',[100000,1222],'basis_account',[5555555,888]],

            'qinshan',['current_account',[1089000,12292],'basis_account',[55555955,888]],

            'jiayou',['current_account',[10000,12292],'basis_account',[55555955,888]]

            ]

animallist=['hippo','rabbit','apple', 'mango', 'carrot']

f = file(shoplistfile, 'w')

p.dump(shoplist,f,True)

p.dump(animallist,f,True)

f.close()


https://img3.mukewang.com/5b3082c60001f70f07470110.jpg

读取:

f = file(shoplistfile)

storedlist = p.load(f)

animallist= p.load(f)


print storedlist

print animallist


结果:

https://img3.mukewang.com/5b3082e7000187e107600085.jpg

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP