JSON is a string that looks like a dictionary!
The dictionary key and value can be in single quotes or double quotes
Definition of Dictionary:
of the JSON string Definition:
Note: 1.json string does not have "variable name =" 2.json Checksum site: http://www.bejson.com/
How can 1.json strings be converted into dictionaries?
First Import JSON module
Then Json.loads (JSON string), it can be converted into a dictionary
2. How do dictionaries convert to strings?
Note: When the dumps method of the JSON string is converted to a string, it will be in the form of \uxxxx when it contains Chinese.
Workaround, use the JSON dumps note parameter Ensure_ascii=false
3. How the file is written to the JSON string
3.1 Convert the dictionary to a JSON string, then open the file and write to it using the Write () method.
3.2 Call Json.dump (dictionary, file), directly open the file, this method directly converts the dictionary into a JSON string, and write to the file,
Note: 1. indent= represents indentation 2. To make the file content look better, you can change the file's suffix to json
Contents of File Written:
4. Read the contents of the file and convert it into a dictionary
4.1 Open the file, read the file, and then convert it into a dictionary using the loads method. I don't know why it's wrong
4.2 Open the file, pass the load method, pass in the file, do not read automatically.
The difference between JSON's dumps (), loads () and the dump (), load () method
There is a need for s to manually write and read the file, without the JSON automatic reading of s to the file.
Python Basics-----JSON module use