python pickle

复制代码
 1 >>> import pickle
 2 >>> m_list=['1',2,'asa']
 3 >>> m_list
 4 ['1', 2, 'asa']
 5 >>> m_file=open('my_file.pkl','wb')
 6 >>> pickle.dump(m_list,m_file)
 7 >>> pickle.close()
 8 
 9 Traceback (most recent call last):
10   File "<pyshell#16>", line 1, in <module>
11     pickle.close()
12 AttributeError: 'module' object has no attribute 'close'
13 >>> my_file.close()
14 
15 Traceback (most recent call last):
16   File "<pyshell#17>", line 1, in <module>
17     my_file.close()
18 NameError: name 'my_file' is not defined
19 >>> m_file.close()
20 >>> m_file=open('my_file.pkl','rb')
21 >>> m_list2=pickle.load(m_file)
22 >>> print (m_list2)
23 ['1', 2, 'asa']
24 >>> 
复制代码
posted @ 2017-09-26 21:52  王思聪6  阅读(196)  评论(0编辑  收藏  举报
友情链接:回力球鞋 | 中老年高档女装