#JSON data exchange, cross-language data exchange. first JSON processing plus ' ' into a string # Json.dumps encapsulated into str,json.loads take out#Pickle is the python internal data exchange language#dic= ' {' name ': ' Cay '} ' write#f=open (' Dog.txt ', ' W ')#F.write (DIC)#Fread=open ("Dog.txt", ' R ') Read#Data=fread.read ()#Print (type (data))#data=eval (data)#Print (Data ("name")) Import jsondic={'name':'cat'}# must double quotation mark {"Name": "Cay"},<class ' str ' > #JSON processing, first put {' name ': ' Cay '}--"{" Name ":" Cay "}---> ' {" Name ":" Cay "} '#dic=[1,2,3]#[1, 2, 3],<class ' str ' >#JSON processing---"' 8 '#dic= ' Hello ' #json处理----"" Hello "----> '" Hello " Data =json.dumps (DIC)# turns all of this into the STR string data type, #Get the string# f=open (' Dog.txt ', ' W ') # f.write (data) #写入f =open ("Dog.txt", "R") #如果是dump就是 #data=json.load (dic,f) json.loads ( F.read ()) #解析数据#data=json.load (f)#data=json.loads (F.read ())Print(data)#The double-cited result is double-lead , and the single-lead result is also double-cited. So the string is best double-citedPrint(Type (data))#Output Data type
JSON is processed as strings, main functions, dumps and loads