Traditional Culture Encyclopedia - Weather inquiry - How does python read the contents of json files?
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).
- Previous article:Why do hamsters chew their teeth?
- Next article:I want to know the telephone number to check the time.
- Related articles
- List the main pollution sources of smog weather in China, and talk about how to prevent smog weather from the perspective of environmental management.
- How many days will the New Year be celebrated this year?
- Chagan Lake Tour Guide Words
- 20 15 how many tourists came to Yili during the summer vacation?
- What Japanese animated films are worth recommending?
- Introduction to the application of psychology major in Leipzig University, Germany
- What are the interesting places in Zhangjiakou on rainy days?
- How to classify wind power levels?
- What have gdr3 and wp8. 1 upgraded?
- What is the lowest temperature in Changsha in 2008?