1 import cPickle as p; 2 3 FCurDir="D:\\1.txt"; 4 MyWList=["A1","A2","A3"]; 5 6 #Write File 7 8 MyWFile=file(FCurDir,"w"); 9 p.dump(MyWList,MyWFile); 10 11 MyWFile.close(); 12 13 #Read File 14 MyRFile=file(FCurDir,"r"); 15 MyRList=p.load(MyRFile); 16 17 for KStr in MyRList: 18 print(KStr); 19 20 MyRFile.close();
原文:http://www.cnblogs.com/Bbrook/p/4345722.html