#!/usr/bin/env python__author__="lrtao2010" #python3.7 JSON module" "to pass an object between different programming languages, you must serialize the object into a standard format, such as XML, but a better way is to serialize it to JSON, because JSON represents a string that can be read by all languages, easily stored to disk, or transmitted over a network. JSON is not only a standard format, but also faster than XML, and can be read directly in the Web page, very convenient. " "" "the process by which objects (variables) become stored or transferred from memory is called serialization, and after serialization, the serialized content can be written to disk or transmitted over a network to another machine. In turn, re-reading the variable contents from the serialized object into memory is called deserialization. " "#JSON rules" "1, the string must use "", single quotation mark error, 2, no matter how the data is created, as long as the JSON format, you can json.loads out, not necessarily dumps data to loads. " "ImportJSON#dic = {' name ': ' Test ', ' age ':#json_dic = json.dumps (DIC)#Print (Json_dic,type (json_dic))#{"Name": "Test", "Age": <class ' str ' >#dic = ' {' name ': ' Test ', ' age ': '#json_dic = json.loads (DIC)#Print (Json_dic,type (json_dic))#{' name ': ' Test ', ' age ': <class ' dict ' >#json_f = ' Json_text.txt '#json_dic = {' name ': ' Test ', ' age ':#with open (Json_f, ' W ') as F:#F.write (Json.dumps (json_dic)) #等同于json. Dump (json_dic,f), dump can only be used to write to disk. #With Open (Json_f) as F:#my_dic=json.loads (F.read ()) #等同于my_dic =json.load (f), load can only be used to read from disk##print (my_dic[' name '])#Test
python3.7 JSON module