标签:import .com img wan ict load com work port
有时候我们需要把我们的变量内容存下来,这时我们就可以用pickle来操作。
存储操作如下所示:
#!/usr/bin/python # -*- coding:utf-8 -*- import pickle list1=[1,2,3,4,5,6] result_file = ‘/Users/tanchao/Documents/pythonwork/CNN_TRY/wang.dict2‘ f=open(result_file, ‘wb‘) pickle.dump(list1, f)
读取操作:
#!/usr/bin/python # -*- coding:utf-8 -*- import pickle result_file = ‘/Users/tanchao/Documents/pythonwork/CNN_TRY/wang.dict2‘ f=open(result_file, ‘rb‘) list2=pickle.load(f) print(list2)
显示:
标签:import .com img wan ict load com work port
原文地址:https://www.cnblogs.com/shixisheng/p/9463907.html