码迷,mamicode.com
首页 > 编程语言 > 详细

Python pickle dump load

时间:2015-09-29 11:31:05      阅读:396      评论:0      收藏:0      [点我收藏+]

标签:

import pickle

with open(‘mydata.pickle‘,‘wb‘) as mysavedata:
    pickle.dump([1,2,‘three‘], mysavedata)
with open(‘mydata.pickle‘,‘rb‘) as myrestoredata:
    a_list=pickle.load(myrestoredata)
print(a_list)

 import nester and print

import pickle
import nester

new_man=[ ]
try:
    with open(‘mydata.pickle‘,‘rb‘) as man_file:
        new_man=pickle.load(man_file)
except IOError as err:
    print(‘file error‘ + str(err))
except pickle.PickleError as perr:
    print(‘pickling error‘ + str(perr))

nester.print_lol(new_man)

 

Python pickle dump load

标签:

原文地址:http://www.cnblogs.com/oskb/p/4845700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!