首页 > 代码库 > python pickle
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 >>>
python pickle
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。