import json
##将FileName指定为你的文件的实际路径
FileName='t.txt'
lst=[{'name':'lili','age':25},{'name':'gg','age':18}]
with open(FileName,'w') as f:
json.dump(lst,f)
##注意:最左边每个=表示一个空格f='你的文件名.txt'
d={('dsaa','dsa'):1.2132,('fdsfsd','dsada'):2.3243}
with open(f,'w') as fo:
====for k,v in d.items():
========print("%s,%s %.4f" %(k[0],k[1],v),sep='',file=fo)
import pickledictfile=open("myfile",'wb')
mydict={"a":[[1,2],[3,4]],"b":[[5,6],[7,8]]}
pickle.dump(mydict,dictfile)
dictfile.close()
dictfile=open("myfile",'rb')
readdict=pickle.load(dictfile)
print(readdict)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)