How does python read the contents of json files?
JSON consists of list and dict in python.
These are two modules for serialization:
Json: Used for conversion between strings and python data types.
Pickle: Used to convert between python-specific types and python data types.
The Json module provides four functions: dumps, dumps, loads and load.
The pickle module provides four functions: dump, dump, load and load.
Json Dump Converts a Data Type to a String Dump Converts a Data Type to a String and stores it in a file? Converts a string to a data type. Load converts file opening from string to data type.
Json can exchange data between different languages, while pickle is only used between python. Json can only serialize the most basic data types, while josn can only serialize common data types (list, dictionary, list, string, number,) such as date format and class object! Qiao Sen can't. Pickle can serialize all data types, including classes and functions.
Example:
Dump: Convert the dictionary in python into a string.
1importjson23test _ dict = {'bigberg':]}] 5print (load _ dict) 67 with open ("../config/record.json", "w") as dump_f:8 json.dump(load_dict, dump_f).